Blueprint: Getting an object to LOOK at another object
I'm trying to create a pair of eyes that will look at an object whenever it moves. In 3ds max this is quite easy to accomplish by simply giving the eyes a "Look at Constraint"
Is there such a function in UE4?
asked Jul 08 '16 at 07:18 AM in Using UE4
You have to make a blueprint that makes the mesh or actor rotate to look at the target location or actor each tick like NukePie explained. The math part is luckily done by UE! :)
Something like this should work:
If you are trying it in code:
If you are trying to make a skeletal mesh look at a target (like aiming) You should take a look at this documentation: https://docs.unrealengine.com/latest/INT/Engine/Animation/AnimHowTo/AimOffset/
I hope this helps!
Without knowing exactly what it is I can only speculate. Bare with this...
Ok, lets say we have a pair of eyes. A Mesh eye ball individually placed inside a skull. In the blueprints you would, possibly, have a tick event or an event that fires from a trigger then loops (performance?), pull from the eyeball mesh and create a function to set rotation.
Next you would need to do a call to find the target you are looking at. For example, get all actors of class with a For Each Loop with Break (again performance...) and find the matching actor and get its location Vector and store that reference as a variable.
Next you would set the eyeball rotation to look towards that vector by setting rotation, this could take some math. I'd suggest a clamp to stop the eye balls spinning into the back of your face.
This is probably a noob approach but I could foresee it working. Maybe not the best method but it might be a good method to try and test and then find optimisations later. (That's how I roll)
answered Jul 08 '16 at 07:42 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here