How do I replicate movement

Get help using Construct 2

Post » Fri Jun 24, 2016 8:14 am

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?
B
9
S
3
Posts: 32
Reputation: 708

Post » Fri Jun 24, 2016 9:04 am

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.
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Post » Fri Jun 24, 2016 12:49 pm

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
B
9
S
3
Posts: 32
Reputation: 708

Post » Fri Jun 24, 2016 2:24 pm

B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Post » Fri Jun 24, 2016 8:07 pm

the ideia is that yes, but doesn't work properly xD but thank you sir
B
9
S
3
Posts: 32
Reputation: 708

Post » Fri Jun 24, 2016 11:38 pm

Okay, what is not working properly? Lets adjust.
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Post » Sat Jun 25, 2016 1:26 am

it has the same problems as mine, if i had platforms, in different y levels, it starts to mess up
B
9
S
3
Posts: 32
Reputation: 708

Post » Sat Jun 25, 2016 9:13 am

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 ?
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Post » Sat Jun 25, 2016 9:27 am

Message: franmcod can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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, https://www.youtube.com/watch?v=Ipvb79JBltA
B
9
S
3
Posts: 32
Reputation: 708

Post » Sat Jun 25, 2016 9:33 am

Thank you, now i have something to pin my head on. Nice challenge (for me), i try this later.
B
33
S
18
G
28
Posts: 2,474
Reputation: 20,912

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek and 7 guests