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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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!

Product Version: UE 4.12
more ▼

asked Jul 19 '16 at 02:12 PM in Blueprint Scripting

avatar image

205 13 25 26

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

2 answers: sort voted first

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.

more ▼

answered Jul 19 '16 at 07:42 PM

avatar image

2.5k 102 66 260

avatar image mdmoberly Jul 19 '16 at 10:08 PM

I am having trouble figuring out what the offset should be.. Just to clarify what I am trying to do, I am selecting an object in the world and once that object is select, it is to remain where it is and then update its location when my character updates its location.

I was able to accomplish this somewhat by setting the actors location to my location - the actors location. But this caused the actor to jump between two locations. The speed of the actor moving was also slower than my characters speed, and they should be the same. here is a short video

Do you have a suggestion on calculating the offset?

Thanks for you help!

avatar image Adam Davis STAFF Jul 20 '16 at 02:05 PM

The attach to actor node can be used and set to maintain relative offset from the player, allowing the actor to update its position based on the player's movement without having to worry specifically which input was entered. This also works for rotation and scale.

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

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.

more ▼

answered Jul 20 '16 at 11:42 AM

avatar image

1.2k 18 23 40

avatar image mdmoberly Jul 20 '16 at 08:17 PM

PERFECT! That is exactly what I was looking for! Works like a charm! Thank you for your help!

(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