How to set actor location in reference to MyCharacter
I want to change an actors location according to my player input. Basically I have a flying character that can select actors in the world, and I want to change their location on the X, Y and Zach axis when my character moves in the X, Y and Z axis.
I tried doing this with an Attach and keeping world position, but the actor rotates when I rotate my character.. I've also tried setting the actors location using the Axis Inputs for MoveForwad and MoveRight, but that did not work either.
Any input would be awesome!
asked Jul 19 '16 at 02:12 PM in Blueprint Scripting
You can use the SetActorLocation node. On the Actor ( that you want to move) Tick function, get the character location, then split the vector, modify how you want such as applying an offset, then SetActorLocation from the vector.
This is probably the simplest way. It may be all you need, or it may look too locked.
You could set a timer call function node on the actor and every x seconds call a function that sets a target location from the character position. Then do a moveto that new location.
I don't remember if there is an option to ignore rotatation in an attach. There may be.
answered Jul 19 '16 at 07:42 PM
If you want to achieve an effect as if your character would carry the actor, then you could check out PhysicsHandleComponent (this wiki page might help you get started).
Otherwise, you could try to do smth like this.
In the very moment you 'select' an actor, you get it's world location, and you subtract it from your character's world location. You store the result under some variable X. In tick, you take that selected actor and set it's world location to your character's location + (or -, don't remember, soz :p) the value you've stored in X variable. That should work and it shouldn't rotate selected actor around your character when you rotate.
answered Jul 20 '16 at 11:42 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here