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"

Rotating an object relative to camera direction

I'm trying to make an object rotate in the same direction relative to the direction the camera is looking. With what I have so far the rotations are correct at 0,90,180,270 degrees but every point in between up to 45 degrees, the rotation gets thrown off and starts rotating diagonally. What I'm hoping is that this is just a simple math problem that I'm overlooking. Thanks in advance!

alt text

Here's a video of what this is doing

Product Version: UE 4.22
rotation.png (376.1 kB)
more ▼

asked Jul 11 '19 at 10:10 PM in Blueprint Scripting

avatar image

1 1

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

1 answer: sort voted first

hey Zawa :)

I'd suggest trying to following approach to start with and see if it fits your needs...

in Begin Play > Get Player Controller > Get Player Camera Manager > Get Camera (store a reference to this camera this as a variable in Begin Play)

on Tick > Get World Rotation of this stored camera actor/component > Rinterp the dynamic Actor's world rotation (zeroing out any irrelevant axes) to the camera's world rotation)

As I frequently bang on about... Ue4 rotators need careful handling, often it's unwise to break out one of the float axes perform an operation on it and plug it back into a rotator. Try always to perform operations like math, rinterp and lerp on full rotators. Floats have no understanding of the special wraps needed at 360,180,90 whereas rotators have it built in.

more ▼

answered Jul 12 '19 at 01:35 AM

avatar image

1.1k 9 17 20

avatar image ZAWA 4 days ago

Hey thanks for suggestion. I just tried this and it is giving the same kind of rotation I have before. Pretty sure I have a simple math problem here, I don't know how to "zero out the axis" at certain points here.

(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