How do I replicate movement

0 favourites
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • Hey, i've been having some problems with this, basically i have 1 player, and 1 or more "ghosts", and these ghosts replicate the player's movement.

    In both, player and ghost, i'm using the latform behavior, simulating left, right, jump, when the player does too.

    My current ideia is, i calculate the time it takes for the ghost to get to the position when the player performs an action. Lets say, when the player jumps, i call a function passing the player's X and Y as arguments, that loops(using for each) all ghosts, setting 2 instance varialbes to the ghosts X and Y, then i wait z seconds, where

    z= distance(Function.Param(0), Function.Param(1), Ghost.X, Ghost.Y) / Ghost.Platform.Speed and then i simluate the jump on the ghost.

    This doesn't work very well in a couple of scenarios, if i have multiple platforms, different Y levels, the ghosts start to derp. Also I have the Wrap behavior, soo if i jump while some ghosts are "wrapping" to the other side, these ones only jump after a while.

    Any tips, maybe a new approach? Thanks in advance!

    PS: the for each loop, does it run in parallel?

  • First thing that comes in my mind is the 'wait'. It does what it is designed to do, but i dont think it does what you expect it to do. (besides that i have no solution for you at this little moment)

    Lets say ... at 12h00 the player jumps. You delay the enemy with 2 seconds. The enemy jumps at 12h02.

    At 12h01 the player and the enemy are closer to each other. The player jumps. Enemy delays with 1 second. So at 12h02 de enemy jumps. Twice ? Nope.

  • Both the player and the ghost are at the same speed, acceleration is very high, so that they reach max speed almost instantly. Yeah i mean i tried with the wait, because i did not know how to do it.

    I mean i could save the position where the player jumps in a list in each ghost, but instance variables can only be numbers,text or bools(i would live to have more than 1 ghost) but still, no ideia how to do this in C2, outside of C2 yeah sure, but here....

    I tought of the wait, because (i can't add images but i'll hammer it) ok so speed = d / t

    G = ghost P = player

    |-------|

    G---- --P if the player jumps here, knowing the distance beetween both, and the speed of the G, i know how long he takes to make that distance right? so waiting that time and then jump, maybe i'm wrong. I know when i call the function, the player and the ghost keep moving, that's why i tried to save the position of both

  • Is this what we talk about ?

    https://www.dropbox.com/s/zqhuotw5ag3by ... .capx?dl=0

  • the ideia is that yes, but doesn't work properly xD but thank you sir

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, what is not working properly? Lets adjust.

  • it has the same problems as mine, if i had platforms, in different y levels, it starts to mess up

  • Do you want them to stay on their platforms ?

    Do you want to give them a mechanic move pattern and react when the player moves towards them ?

  • nono, its just a ghost, it copies everything the player does, if the player is moving left, the ghosts move left, if the player jumps at X,Y, the ghosts jump at the same X,Y, basicly a delayed shadow, i'm trying to make this mechanic, youtube.com/watch

  • Thank you, now i have something to pin my head on. Nice challenge (for me), i try this later.

  • ok awsome! let me know if u make progresses plz

  • Should have posted this after your exams. But hey.

    https://www.dropbox.com/s/ffbcqx2urfwig ... .capx?dl=0

  • Have u made any progress?

  • You can do it by saving the player's positions to an array and setting the ghost's position from that.

    Example here:

  • That is exactly what i did.

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