Announcement

Collapse
No announcement yet.

How to move an object to player

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to move an object to player

    Hi peoples.
    I thought I'd be able to figure this one out but apparently not.
    Basically I'm trying to get an object to float towards the player and then destroy its self when it reaches the player. Think of Crash Bandicoot collecting apples.
    This is the blueprint I've made so far.
    Click image for larger version

Name:	ActorMoveToCharacter.PNG
Views:	1
Size:	115.5 KB
ID:	1149428

    The problem I'm having is that the object doesn't move to the player, instead it moves away from the character to the same location each time.
    I'm sure it's probably really easy and I'm just missing something silly.

    Anyone got any ideas?

    Thanks!

    #2
    I would guess you are not getting the right value for your player location. Putting a print screen node that prints the player location should help track this down.

    You could try using "get player controller" or "get player pawn" and see if either of those works for you.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #3
      Hi Thanks for the response. I've added the Print String node before the Move Component To node and it displays my characters location but I'm not sure what to do with the location it returns. Also I just tried the Get Player Pawn which gives me the same result and if i use the Get Player Controller node the object slightly moves upward and then gets destroyed.
      My current BP:
      Click image for larger version

Name:	ActorMoveToCharacter2.PNG
Views:	1
Size:	146.8 KB
ID:	1075854

      Any other ideas? I'll upload a video so you can see whats actually happening.

      Comment


        #4
        Here is a video:


        Thankss!

        Comment


          #5
          Try it like this.

          OnComponentBeginOverlap > Cast to "YourCharacter" > Move Component To > Destroy Actor

          Hook the Other Actor from the Overlap to the Object on the cast. Then from the Return "As YourCharacter" pull out a Get actor location. Then do the Move Component To.
          Last edited by DEDRICK; 05-06-2015, 03:16 PM.

          Comment


            #6
            Hi, I've just tried and i still get the same result. Maybe I haven't set it up properly?
            Click image for larger version

Name:	ActorMoveToCharacter3.PNG
Views:	1
Size:	136.6 KB
ID:	1075855

            Thanks.

            Comment


              #7
              How are the components set up on the apple actor? Is Apple the root component for the actor and is it Static or Moveable?

              Comment


                #8
                This is how its set up.
                Click image for larger version

Name:	ActorMoveToCharacter4.PNG
Views:	1
Size:	415.4 KB
ID:	1075857
                I'm not sure if I'm supposed to put a Scene component in there but without it I was unable to change the size of the trigger volume.

                Comment


                  #9
                  Try Plugging "Scene" into the Move Component instead of Apple, make sure Scene is "Moveable" as well. Alternatively you make Apple the Root Component

                  Comment


                    #10
                    I think the problem must be the Move Component To node because if I use the Set World Location node instead, the apple snaps right to players location. Hmmmm I'm not sure what else to try.

                    Comment


                      #11
                      Ahh DEDRICK that kind of worked. The Apple moves to the player but it only moves to the location of the character when the trigger was activated. I need the object to follow the character until it reaches the character before it disappears.

                      Any ideas?

                      Thanks!

                      Comment


                        #12
                        It is because that node is only being triggered once on the overlap event.

                        For what you are wanting, you need to look into the "VinterpTo" node. This 'pure' node needs a companion "set world location" or other such node which would be fired on Tick and you need to use your begin/end overlap events to control it using a gate or some other logic.

                        For this you need to plug the AppleBP current location to current and the player location to target. Deltatime should come from your eventtick node and interpspeed you will want to mess around with.
                        Ryan Brucks
                        Principal Technical Artist, Epic Games

                        Comment


                          #13
                          Originally posted by AutoLiMax View Post
                          Ahh DEDRICK that kind of worked. The Apple moves to the player but it only moves to the location of the character when the trigger was activated. I need the object to follow the character until it reaches the character before it disappears.

                          Any ideas?

                          Thanks!
                          That makes sense because it is a one time snapshot of the location. What Ryan suggested above should work but you will also need a way to kill the actor or it will move endlessly. Hooking a Destroy actor after Set World Location will kill it instantly. You will need a Branch and some logic to check the distance between current actor location and player so when it gets close enough it destroys itself.
                          Last edited by DEDRICK; 05-06-2015, 04:43 PM.

                          Comment


                            #14
                            Hi Thanks for the help its finally coming together. The only problem is like you say it won't stop following me. This is what I have so far:
                            Click image for larger version

Name:	ActorMoveToCharacter5.PNG
Views:	1
Size:	205.6 KB
ID:	1075865

                            I'm trying to work out the distance between the character and the actor but it doesn't seem to be working.

                            Comment


                              #15
                              Actually It's working. I just needed to set the over time to 0 and the interp speed to a higher value.

                              Thanks a lot, i would have probably been here for days trying to figure it out.

                              Comment

                              Working...
                              X