UE4: C++ Actor Tick Problem

Hello there,

I am having an issue where I have an actor rotate base on delta time from tick. I notice that tick doesn’t increase, it stays at a certain point and my actor will not rotate correctly. My actor seems to be sticking at 90 degrees rotation, can someone explain to me why C++ deltatime is not advancing?

DeltaTime represents the amount of time that has passed since the last time Tick was called. It does not represent the total amount of time the program has been running. If your game is running at 60 frames per second, for example, DeltaTime will always be 0.01667 seconds.

There is an Actor component that will rotate your Actor over time. Alternatively, you can just add some amount of rotation to your Actor every tick, multiplied by the delta time and some other number that represents speed.

I see, Is there a tick method that allows me to rotate a object over time?

or even a variable?

I was trying to multiply the deltatime with a float value to get a new number and add it to the actor, but it was giving me weird effects.

Here is my code:

    FRotator curRot = GetActorRotation();
    float deltaRot = DeltaSeconds * 50.0f;

    if (curRot.Pitch >= 360.0f)
        curRot.Pitch = 0.0f;

    SetActorRotation(FRotator(curRot.Pitch + DeltaSeconds, curRot.Yaw, curRot.Roll));

Change it to this:

FRotator curRot = GetActorRotation();
curRot.Pitch += DeltaSeconds * 50.5f;
SetActorRotation(curRot);

Thanks for cleaning up my code! :slight_smile: but unfortunately It is still stopping 1/4 of the way there. Rotates 90 degress and stays there. Maybe there is a better way of rotating the actor without my way?

Something else must be stopping it from rotating.

also if there is a way, i would like to show you my cpp and .h file

There we go. Tell me what you think.

link text

I have a txt file that has my .h and .cpp file. can you have a look and see if there is anything else?

link text

Sorry, I wasn’t able to figure it out just from that :frowning:

That is fine. I do have a backup of how to do some rotation, but I was really pushing forward with manual rotation. the other way I had in mind is using a timeline and return a float off of that.