MoveTo: Move To Object with different frames

0 favourites
  • 6 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hi there!

    I have an object with the MoveTo behavior. I also have 4 different objects that I want the object to move to, let's call them Box1, Box2, Box3, Box4. When the object has arrived to Box1, it will move to Box2, then to Box3, then to Box4, then back to Box1 and round and round it's goes. Is there a way to make the object move to one Box with a current frame? I mean, instead of having four different boxes, I want to have one box with four frames.

    When the object has arrived to Box(frame 0) move to Box(frame 1) and so on. Hopefully you understand what I am trying to say.

    Thanks in advance,

    Tommy

  • You can save the current target's frame in a variable. When the object has arrived, increase the variable by 1, pick the box instance with animation frame=variable and move to it.

    Object On Arrived : Add 1 to frameVar
    
    .. Box compare animation frame = frameVar : Object move to Box
    
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dop2000 - My lousy English probably makes it difficult to understand what I mean so I made a video instead. If you watch this video, the blade is the object with the MoveTo behavior and there are 6 different (invisible) objects that they are moving to. The blade object has an Instance variable that changes when the object has arrived. I want to just have 1 invisible object instead of 6 different ones. There will be around 20 blades in the same level so it's kind of messy.

    Subscribe to Construct videos now
  • The principle is the same - you can use an instance variable TargetFrame on the blade sprite. When it arrives, increment the variable, pick the invisible box with that frame and move to it. If the variable=4, reset it back to 0 to make a loop.

    However, you have multiple groups of blades+boxes in your video, this makes it a bit more difficult, because you also need some way to pick the box from the same group. I would probably use hierarchies - create another invisible sprite, say Room. Add blades and boxes to the Room as children. When a blade arrives, pick its parent room, and then pick the room's child boxes.

    I suggest you try to make it working with one group of blades+boxes first.

  • A thousand thanks for helping me out :)

    Yeah, it would've been easy if it was just one blade.

  • dop2000

    I decided to use the 8Direction behavior instead. Now everything works great and it's easy. I have an invisible box with 4 frames. When the blade collides with the box it changes the blades instance variable depending on the frame of the invisible box. The instance variable tells the blade which direction to go :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)