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"

Line trace lock on

Is there a way to get a line trace to lock onto a target. I have a turret that I control with a line trace attached, I want to be able to control the sight, but once my target lines up with the crosshairs (line trace) the way I like, I press a button and the turret then auto locks onto the target and follows it. My turret is elevated pointed towards the ground where the targets are (all targets are moving towards the turret, never away)

Also, for extra credit, can a line trace do some math and let me know the angle (in degrees) from the turret to the ground target? Since the line trace would be locked on, the angle is constantly updating the degrees smaller and smaller until the target is reached. I'll need to use that data for certain functions later on.

Product Version: UE 4.19
Tags:
more ▼

asked Jun 27 '18 at 08:49 PM in Blueprint Scripting

avatar image

live4film
10 3 10

avatar image live4film Jun 27 '18 at 10:01 PM

Thanks! I'll give that a try. But is there a way to do that without an event tick? Maybe a timer function? My game has too many event ticks so I'm going through all my blueprints and finding alternatives where I can.

avatar image live4film Jun 27 '18 at 10:06 PM

Or start ticking when the player is within a certain distance from the turret. So when I walk up to it it starts and when I leave the area it stops

avatar image ThompsonN13 Jun 27 '18 at 10:16 PM

yea you could use a timer instead of tick. all that part does is update the turrets rotation so its really up to you how often you want the rotation to update. you can also set the tick interval for each blueprint class in the class settings. as for the starting and stopping thats something you could easily script as well, the way i had it setup in the above picture is that it will only update the rotation when it has a target. the same type of thing could be applied to have a condition based on distance to target or line of sight or whatever else you like.

avatar image live4film Jun 27 '18 at 10:19 PM

Cool! Thanks for your help

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

1 answer: sort voted first

for the lock on all you really need to do is on button presses do a single line trace and take the hit actor and assign it to a variable. then have another function that sets the rotation of your turret to the look at rotation between the turret and the target.

the setup in this picture should help get you started.

alt text

capture.png (316.5 kB)
more ▼

answered Jun 27 '18 at 09:54 PM

avatar image

ThompsonN13
10.1k 33 10 25

(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