how to move object?

Get help using Construct 2

Post » Mon Mar 03, 2014 11:22 pm

Image
how objects move the object from x to y with a smooth move
if anyone can please help
B
6
Posts: 25
Reputation: 379

Post » Tue Mar 04, 2014 5:51 am

You could use lerp.

Here is a link to a discussion on how to use it.
https://www.scirra.com/forum/viewtopic.php?t=64020&start=0#286732
B
42
S
20
G
31
Posts: 685
Reputation: 20,221

Post » Tue Mar 04, 2014 6:44 am

I really like rex' moveto plugin: viewtopic.php?t=63156&start=0
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Tue Mar 04, 2014 7:16 am

THere are tons of ways.

The most beautiful is using rex' moveto plugin as Rabenmutter suggested. But, if you are like me and don't want to use 3rd party plugins out of fear that they are compatiable down the road.

Then bullet behavior is pretty cool and does a fantastic job.
Open C2
Click New
Now scroll down list till you see move to mouse its past the 8 direction stuff and near the line of sight template.

Its great hey ;)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Tue Mar 04, 2014 8:29 am

Code: Select all
// se the movement parameters
Global number xA = 10
Global number yA = 20
Global number xB = 100
Global number yB = 120
Global number speed = 100

// some variables used in runtime
Global number dist = 0
Global number t = 0

System: trigger once
     -> System: set dist to distance(xA,yA,xB,yB)

System: t<1
      -> System: set t to min(1, dt*speed/distance)
      -> Sprite: set X to lerp(xA,xB,t)
      -> Sprite: set Y to lerp(yA,yB,t)


With that you have a clean, precise and constant motion from A to B
note that lerp isn't some magic function.
lerp(a,b,t) = a + (b-a) * t
no more, no less. You give it 3 values, it gives you one.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511


Return to How do I....?

Who is online

Users browsing this forum: alextro, tarek2, wenwen11212016 and 7 guests