Announcement

Collapse
No announcement yet.

Help:complex rotaion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    I'm pretty sure you could also achieve this with a skeletal mesh pretty easily.

    Leave a comment:


  • replied
    I did something similar a while back. I made some modifications to suit your needs a bit better, and cleaned up the code a bit.

    Without modification, this code will add a new Actor called 'RotoCube' to the Actor Browser>Uncategorized. You can then place it in your map. When the level starts, the cube will be rotating slowly. When you shoot the cube, it will spin faster and move up 500 units over 2 seconds. It will spin very fast for 3 seconds. Then it will do the reverse and happily spin until it is shot again.

    That said, I'm sure you can get this to work with triggers--probably fairly easily--but not sure how exactly to go about that. Also, there is no interpolation with the speed changes. This can be done with some relatively simple math.

    Hope it's some help, and maybe someone else can jump in with how to change states using triggers.



    Code:
    class RotoCube extends Actor
    	placeable;
    	
    var float rotSpeed;		//default rotation rate
    var float riseSpeed;	//rotation rate while moving up and down
    var float maxSpeed;		//rotation rate while spinning fast
    var float fallTime;		//time it takes from high to low
    var float highTime;		//time spent at high position
    var float riseTime;		//time it takes from low to high
    var float riseAmount;	//amount you want to move your mesh
    var DynamicLightEnvironmentComponent LightEnvironment;
    
    auto state Spinning		//our default 'slow spinning' cube
    {
    	event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) 
    	{
    		GotoState('GoingUp'); 
    	} 
    	
    	event Tick(float DeltaTime)							//Called each frame
    	{
    		local rotator final_rot;						//variable to hold our cube's location
    		
    		final_rot = Rotation;							//gets the current location
    		final_rot.Yaw += Round((DeltaTime * rotSpeed) * 65536);	//Adds rotation to the current location.
    		SetRotation(Normalize(final_rot));				//Sets the rotation of our cube with the new rotator value from above
    	}
    	
    }
    
    state GoingUp
    {
    	event Tick(float DeltaTime)
    	{
    		local rotator final_rot;
    		local vector final_loc;							//variable to hold our cube's location
    		
    		final_rot = Rotation;
    		final_loc = Location;							//gets the current location
    		final_rot.Yaw += Round((DeltaTime * riseSpeed) * 65536);	
    		SetRotation(Normalize(final_rot));
    		final_loc.z += (DeltaTime / riseTime) * riseAmount;	//adds our increment value to the location's Z component
    		SetLocation(final_loc);							//Sets the location of the cube to the new value from above
    	}
    	
    	ignores TakeDamage;
    	
    	Begin:
    		Sleep(riseTime);			//Time it takes to go up.
    		GotoState('SpinningFast');
    }
    
    state SpinningFast
    {
    	event Tick(float DeltaTime)
    	{
    		local rotator final_rot;
    		
    		final_rot = Rotation;
    		final_rot.Yaw += Round((DeltaTime * maxSpeed) * 65536);
    		SetRotation(Normalize(final_rot));
    	}
    
    	ignores TakeDamage;
    	
    	Begin:
    		Sleep(highTime);			//Time spent spinning fast
    		GotoState('GoingDown');
    }
    
    state GoingDown
    {
    	event Tick(float DeltaTime)
    	{
    		local rotator final_rot;
    		local vector final_loc;
    		
    		final_rot = Rotation;
    		final_loc = Location;
    		final_rot.Yaw += Round((DeltaTime * riseSpeed) * 65536);
    		SetRotation(Normalize(final_rot));
    		final_loc.z -= (DeltaTime / fallTime) * riseAmount;
    		SetLocation(final_loc);
    	}
    	
    	ignores TakeDamage;
    	
    	Begin:
    		Sleep(fallTime);			//Time spent going down
    		GotoState('Spinning');
    }
    
    defaultproperties
    {
    	begin object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
    		bEnabled=TRUE
    	end object
    	LightEnvironment=MyLightEnvironment
    	Components.Add(MyLightEnvironment)
    	
    	begin object class=StaticMeshComponent Name=BaseMesh
    		StaticMesh=StaticMesh'EngineMeshes.Cube'
    		LightEnvironment=MyLightEnvironment
    	end object
    	Components.Add(BaseMesh)
    	
    	CollisionComponent=BaseMesh
    	bCollideActors=True
    	bBlockActors=true
    	
    	//Rotation and Location values
    	rotSpeed= 0.05		//rotation rate at low position
    	riseSpeed = 1		//rotation rate while going up/down
    	maxSpeed= 1.5		//rotation rate at high position
    	riseTime= 2.0		//time it takes to go from low to high
    	highTime= 4.0		//time spent in the high position
    	fallTime= 4.0		//time it takes to go from high to low
    	riseAmount = 500	//amount to move in the Z direction
    }

    Leave a comment:


  • started a topic Help:complex rotaion

    Help:complex rotaion

    Here is the plan: i want to make a mesh spin, and then when you activate a trigger, i want the mesh to tanslate up in the z axis and spin faster,

    Problem: the spin faster bit is eluding me,

    right now i have to meshes (interp actors both of them) 1 is visible and rotates using rotateRate and phys: rotate (works fine)
    the second one starts hidden but is swapped out with the first one with kismet (again works) the issue arrives when i try to implement the matinee to make the mesh go up and down.
    if i want to use RotateRate then the physics needs to be set at Rotate but in order for the matinee to work it needs to be set to interpolating (or something close).

    Needs: i want the second mesh to raise (hence the need for matinee) and rotate indefinitely (which is why i don't think i can just do it using matinee)

    Anyone know of a better way?
Working...
X