Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Rotate an object to a set rotation at a set speed

What I'm trying to achieve is being able to set a direction and have the object point its "feet" in that direction

 const FVector objectDown = -PhysicsBody->GetUpVector();
 const FQuat ObjectQuat = PhysicsBody->GetComponentQuat();
 const FQuat DeltaQuat = FQuat::FindBetweenVectors(objectDown, GravityDirection);
 const FQuat TargetRotation = DeltaQuat * ObjectQuat;

This gives me how much I need to rotate the object by to achieve the right orientation (TargetRotation) but what I can't get is the "over time" part just right, I've tried Lerping and Interpolation but while these methods do work they vary depending on how much rotation the object needs to do and they slow down as the object gets closer and closer to the target.

Is there a method that will rotated an object to a rotation at a select speed? example:(5 deg/second * DeltaTime)

Product Version: UE 4.21
more ▼

asked Feb 22 '19 at 11:50 PM in C++ Programming

avatar image

6 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Using a timeline. Not sure how when coding though, easy in blueprints.

more ▼

answered Feb 23 '19 at 12:08 AM

avatar image

Crowley Caine
643 8 9 15

avatar image Armetron Feb 23 '19 at 12:16 AM

I considered using a timeline and while that would keep the rotation constant the rotation rate would differ depending on how much I needed to rotate.

example 90 degrees would be done in one second but 180 degrees would also be done in one second, the 180 would be done faster

avatar image Crowley Caine Feb 23 '19 at 12:22 AM

Not necessarily. Because the time of the event from the timeline does not need to be used, you can just use it as a graph for rate of change. Ie per time interval you rotate x amount until the desired roration is achieved.

Can do that with a simple variable function too.

Again, I don't know how to code it but by logic you would know either the desired rotation or the desired direction of the player after it's done rotating. So you'd rotate x amount every delta time until desired rotation is achieved.

Or by using interpolation and some math behind the time portion, ie decide how long it should take to rotate based on rotation needed.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question