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"

GetEnemyLocation

A new quest for you men! I basically have a script written with a trace channel that tries to get the location of the pawn touched. The cast of course succedes but I don't know how to make it permanent. Basically I want to know the location of the pawn touched last time, all the time. Get I have a glimpse? kind regards, Alex

Product Version: UE 4.12
Tags:
more ▼

asked Aug 13 '16 at 07:38 PM in Blueprint Scripting

avatar image

Isadora
16 6 6 7

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

2 answers: sort voted first

What you're doing after the Cast to Pawn is setting "Lock On" to true, setting the current location of that pawn as a variable, and printing that value as a string. This all happens one time when you initially cast to that pawn.

What you should do is right click on the "As Pawn" output of the Cast to Pawn node and promote that value to a variable called PawnTouched. Any time this cast node is called, it will change the value of this PawnTouched variable to the new Pawn actor. (If you need to track multiple pawns in this way, you would instead add that to an array of pawns.)

alt text

Then, don't get the location after the cast. Do it on the Tick Event so that it updates every tick. (Or set up a Timer By Event loop to check every n seconds.)

EventTick Setup: alt text

Timer By Event Setup: alt text

As for Lock On, you could keep this as it is if you just want to tell your character that he's locked onto something. Or you could move it to the AI Pawn and get/set off of casts. Just depends what mechanic you need that variable to drive, really.

promotetovar.png (41.9 kB)
tickevent.png (96.3 kB)
more ▼

answered Aug 14 '16 at 10:13 AM

avatar image

rbmiracle
232 10 9 23

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

Right click on the variable being output by the cast and click store as variable. This will add the variable automatically to the list of existing variables in your blueprint. You can use it any time you like. If you are not sure it is already set, you could use an IsValid node on it before getting its location.

more ▼

answered Aug 13 '16 at 09:57 PM

avatar image

Roel
2.4k 70 43 142

avatar image Isadora Aug 14 '16 at 07:25 AM

I don't understand. So i have the position in X Y Z but I can't get that store as variable.alt text

I think I am missing something...

help.png (189.2 kB)
avatar image Isadora Aug 14 '16 at 07:29 AM

I think it's only get the location without keeping track of it.

avatar image Roel Aug 15 '16 at 02:02 PM

Store the pawn instead o the actor location, and every frame you need the location you can do "Get Actor Location" on the stored pawn.

(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