Download

Rotating a static mesh using unrealscript

I’d like a windmill type effect on a mesh that I’’ spawning in via unrealscript, such that the mesh continually rotates.

Any tips on how I can do this?

Should I be spawning in a matinee for this?

Thanks in advance.

I ended up doing this, which works great:



class MyRotatingActor extends StaticMeshActor;


//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Default properties
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
defaultproperties
{    

    Begin Object Name=StaticMeshComponent0
        StaticMesh=StaticMesh'Somemesh'
    End Object

    bStatic=false
    bMovable=true

    Physics=PHYS_rotating
    RotationRate=(Pitch=0,Yaw=20000,Roll=0)
}


In the tick, get the actor rotation, add to rotation.yaw a value*Deltatime, then do a actor.setrotation(rotator).

Weird to ask for a static mesh to rotate… Interpactor surely.
-anyway, just incase anyone else searches for a similar category this code is available online.




/**
 * Copyright Copyright 2013-2014 rero, Inc. All Rights Reserved.
 */
class BLRotateToAngle extends Actor
    ClassGroup(BLActionContent)
    dependson(CylinderComponent)
    placeable;
    /**
     * BLRotateToAngle 
     *    @description: 
     *   Rotae a Mesh by touching it
     * @author        rero
     * @version       v1
     *   @link          Placeholder for a link to our website
     */
/////////////////////
// var declaration //
/////////////////////
var() 									float 		RotateDegree;

var 									Rotator 	InitRotation;
var 									Rotator 	RotatDelta;
var(BLRotateToAngle,Stepping) 			int 		SteppingCount;
var 									int 		SteppingCounter;
var float deltaRotation;


/** Base cylinder component for collision */
var(BLRotateToAngle,MeshColission) editconst const CylinderComponent	CylinderComponent;
/**
 * Configure your own Mesh here * Should be a bottom center pivot Mesh!! Check collision then too!!
 */
var(BLRotateToAngle,MeshColission) StaticMeshComponent SMComponent;
//var(BLRotateToAngle)	SoundCue				SoundOnMove;
var(BLRotateToAngle) AudioComponent			BLAudioComp;

function PostBeginPlay()
{
	InitRotation = self.Rotation;
	deltaRotation = RotateDegree * DegToUnrRot / SteppingCount;
	SteppingCounter = SteppingCount;
	
}

event Tick (float DeltaTime)
{
	local Rotator newRotation;

	if (SteppingCounter > 0)
	{

		SteppingCounter--;
		//deltaRotation = RotateDegree * DegToUnrRot;// * DeltaTime;

		newRotation = Rotation;

		newRotation.Yaw += deltaRotation;
		//newRotation.Yaw = deltaRotation;

		SetRotation( newRotation );
	}


	//SetRotation(RInterpTo(Rotation,newRotation,DeltaTime,1));
}

defaultproperties
{

    // Have some DynamicLightEnvirementCompponent
	Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
		bEnabled=TRUE
    End Object
    Components.Add(MyLightEnvironment)

    // Use a StaticMeshComponent
    begin object class=StaticMeshComponent Name=BaseMesh
	    StaticMesh=StaticMesh'BL_Castle.StaticMeshes.Wall_BlockTop'
	    LightEnvironment=MyLightEnvironment
    end object
    Components.Add(BaseMesh)
	SMComponent=BaseMesh

	// Use a CylinderComponent for colition enhancment so we can trigger
	// copied from Trigger
	Begin Object Class=CylinderComponent NAME=CollisionCylinder LegacyClassName=Trigger_TriggerCylinderComponent_Class
		CollideActors=true
		CollisionRadius=+0150.000000
		CollisionHeight=+0130.000000
		bAlwaysRenderIfSelected=true
	End Object
	CollisionComponent=CollisionCylinder
	CylinderComponent=CollisionCylinder
	Components.Add(CollisionCylinder)
	
    // Add a Sound via AudioComponent
	Begin Object Class=AudioComponent Name=AudioComp
		//SoundCue=A_Ambient_Loops.Water.Waterfall_Medium_02_Cue
		SoundCue=SoundCue'BL_Sound.Rock.BL_rock-scrape-2_Cue'
		bAutoPlay=true
	End Object
	BLAudioComp=AudioComp
	Components.Add( AudioComp )

	// Look at the Move and MoveSmoth link is in the TopNote
    bCollideActors=true
    bBlockActors=true

    RotateDegree=90
    SteppingCount=64
}


Used it years ago. pretty sure its fine*

Links:
// Romero UnrealScript: Playing Sounds in UnrealScript