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
asked Aug 13 '16 at 07:38 PM in Blueprint Scripting
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.)
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.)
Timer By Event Setup:
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.
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.
answered Aug 13 '16 at 09:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here