x

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"

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?

Product Version: UE 4.12
Tags:
more ▼

asked Jul 08 '16 at 07:18 AM in Using UE4

avatar image

pdcsky
29 8 9 12

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

2 answers: sort voted first

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: https://docs.unrealengine.com/latest/INT/Engine/Animation/AnimHowTo/AimOffset/

I hope this helps!

Elias

lookattarget.jpg (85.5 kB)
more ▼

answered Jul 08 '16 at 10:17 AM

avatar image

PasteDog
1.2k 24 16 53

avatar image pdcsky Jul 08 '16 at 01:04 PM

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?

avatar image PasteDog Jul 08 '16 at 03:35 PM

How you describe it it sounds like AimOffset, take a look at the link in my previous comment :)

avatar image Dragontiger Apr 25 '17 at 09:10 PM

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.

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

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!

more ▼

answered Jul 08 '16 at 07:42 AM

avatar image

TechnicallyLew
134 7 3 8

(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