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"

Animate based on line trace

Hello all,

I'm trying to make a system where a character holds a flashlight at their side and points it via animation toward the output location of a line trace. Ie, when a character is close to a wall, the light will be pointed up to point at where the characters is looking, and as the character walks backward, the light would be held slowly more level to continue pointing at the right place. Any idea how to make the animation work based on line trace?


Product Version: UE 4.20
more ▼

asked Sep 21 '18 at 08:38 PM in Blueprint Scripting

avatar image

19 1 6 9

avatar image mightyenigma Sep 22 '18 at 07:07 AM

It sounds like it would be easier just to follow the control pitch like weapons do in FPS template? How is what youre describing different from aiming a typical fPS gun?

avatar image Sauntiago Sep 22 '18 at 12:54 PM

Well the difference is that I have the first person camera in the head which is no different from the FPS gun, but the flashlight is being held in the hand with a light cone in it. I need basically an aim offset for the flashlight to aim where my camera is. If i didn't, when I stood close to a wall the flashlight would be pointed at the wall down by my hip and what I'm looking at wouldn't be lit up.

avatar image mightyenigma Sep 23 '18 at 04:41 AM

oh you mean the flashlight is attached to the character's hand on their third person skeleton so you need to get the hand to follow the camera so the flashlight points where you are looking?

avatar image Sauntiago Sep 23 '18 at 12:51 PM

Exactly! An aim offset of sorts.

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

1 answer: sort voted first

I'm not sure what the best way is but I think you dont need a trace. I think you could just add a scene component or a socket to your pawn's camera, at a some distance away but attached so that it is always in the center of your viewport no matter which way you turn your head.

Then every Tick you can have the Flashlight or the Bone holding it rotate to the LookAt rotation from the flashlight to the scenecomponent. Or something like that.

I havent done anything with skeletal animations yet so i dont know how aimoffset works. if aimoffset is some kind of float between 0 and 1 then maybe you can use my idea and get the dot product between the camera forward vector and that LookAt vector and use the result of that somehow.

more ▼

answered Sep 23 '18 at 08:14 PM

avatar image

3.8k 18 23 20

(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