Move a sprite from point A to point B?

Get help using Construct 2

Post » Thu Jul 25, 2013 6:34 pm

Thank you very much gentlemen.

I was hoping to avoid the lerp route as my last project ended up 1000 events and it became an unmaintainable mess.

I just tried out rex moveTo pugin, and it works exactly as I need. I am very surprised that C2 have not added moveTo as a built in - its very very useful and saves a lot of work. I only hope it handles layer scaling.

Pathfinding looks interesting, but for balls moving a few cm vertically in a bingo game, pathfinding is probably overkill (assuming it will treat all my UI elements as non solids?)
Ill checkout liteTween also.

All great suggestions - thanks again.nutmix2013-07-25 21:51:57
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Thu Jul 25, 2013 6:49 pm

Without using unofficial plugins, you can use the Timer object to lerp (linear interpolation) between 2 values smoothly.

For example;

Set timer to 1 second

every tick;

lerp(x1, x2, timer.CurrentTime / timer.Duration)
lerp(y1, y2, timer.CurrentTime / timer.Duration)

and because the timer resets to zero, you need to add;

OnTimer | set position to x2, y2
B
12
S
5
G
2
Posts: 59
Reputation: 3,859

Post » Thu Jul 25, 2013 7:17 pm

@nutmix just use search, there's quite few posts about that

@David Flook don't need timer for that
Every tick: lerp(self.x,targetX,dt)
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,835

Post » Thu Jul 25, 2013 7:47 pm

But to be clear, it's not the same movement right?

Lerping self to target will create movement that starts fast and slows as it approaches the target. Is that correct?
B
12
S
5
G
2
Posts: 59
Reputation: 3,859

Post » Thu Jul 25, 2013 7:55 pm

@shinkan

The timer probably provides the easiest way of controling the movement speed, while still remaining fps independant.

@David Flook

Lerping that way will provide a linear movement, since dt is somehow constant, so no speed fluctuation.Magistross2013-07-25 20:27:38
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Thu Jul 25, 2013 8:43 pm

@nutmix
pathfinding is now a behaviour very new so try it out
it's official and not a third party plugin just look under behavious in an updated releaseDrGreenThumbCAN2013-07-25 20:50:16
B
41
S
12
G
6
Posts: 136
Reputation: 6,372

Post » Thu Jul 25, 2013 9:42 pm

LiteTween offers basic to complex movement options.
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Thu Jul 25, 2013 9:46 pm

Thank you very much gentlemen.
I was hoping to avoid the lerp route as my last project ended up 1000 events and it became an unmaintainable mess.
I just tried out rex moveTo pugin, and it works exactly as I need. I am very surprised that C2 have not added moveTo as a built in - its very very useful and saves a lot of work.
Pathfinding looks interesting, but for balls moving a few cm vertically in a bingo game, pathfinding is probably overkill (assuming it will treat all my UI elements as non solids?)
Ill checkout liteTween also.

All great suggestions - thanks again.nutmix2013-07-25 21:48:10
B
17
S
6
G
3
Posts: 370
Reputation: 3,942


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION, Yahoo [Bot] and 18 guests