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?
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?
Hi pdcsky,
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)
Good luck!
Hello!
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:
//Calculates the lookat rotation from direction vector
FVector direction = FVector::ForwardVector;
FRotator lookAtRotator = FRotationMatrix::MakeFromX(direction).Rotator();
If you are trying to make a skeletal mesh look at a target (like aiming) You should take a look at this documentation: [Creating an Aim Offset | Unreal Engine Documentation][2]
I hope this helps!
Elias
Awesome help guys! I gave the thing a try and it seems to do the trick,
what about if I wanna get 2 eyeballs that are boned up looking at each other and will keep on looking even if they’re moving?
How you describe it it sounds like AimOffset, take a look at the link in my previous comment ![]()
Can someone do a tutorial for a newbie. I’m trying tu do a short animation inside UR and a detailed tutorial of the eyes look at object will be very useful.