Jump to content

Proper object rotation


photo

Recommended Posts

Hi,

 

I have some problems with rotating objects manually via Unigine Script and Game Framework. First my entity are moving to an DestinationPosition with following code:

vec3 pawn_direction = DestinationPosition - curPosition;
curRotation = lerp(curRotation,quat(setTo(Vec3_zero,pawn_direction,vec3(0.0f,0.0f,1.0f))),iFps * TurningSpeed);
curPosition += normalize(pawn_direction) * iFps * MovementSpeed;
PhysicalPawn.setWorldTransform(translate(curPosition) * curRotation);

No problem with that. After my entity is reaching the DestinationPosition, they should rotate to an DestinationRotation which is of type quat(0.0f,0.0f,1.0f,destination_angle). But after a long try and error I can't get the right solution to get working.

I tried following code from the samples/objects/mesh_01:

PhysicalPawn.setWorldTransform(Mat4(PhysicalPawn.getWorldTransform() * quat(0.0f,0.0f,0.0f,ifps * TurningSpeed)));

and from samples/materials/2d_00:

PhysicalPawn.setWorldTransform(PhysicalPawn.getWorldTransform() * Mat4(rotateZ(ifps * TurningSpeed)));

All without any success. What I'm doing wrong? PhysicalPawn is of type PlayerActor. Ist that my problem? If anyone can get me just a hint it will be much appreciated.

 

Thanks.

Link to comment
×
×
  • Create New...