Good behaviour for ease movement?

Get help using Construct 2

Post » Fri Mar 03, 2017 5:18 pm

@99Instances2Go
yeah the problem is mostly visible when using touch using on mouse down condition. if object is at standstill, and i click somewhere else regular lerp(sprite.x,mouse.x,0.1) will start fast & decelerate towards that point, where i want the sprite to first accelerate.

I need some kind of modifier for inertia or torque that increases from 0 to 1 dynamically in some way, to simulate the acceleration.

Maybe if i can get the XY position of a middle point between sprite and target and use that instead of the mouse,
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Fri Mar 03, 2017 6:25 pm

@tunepunk
That js code you posted is the same as lerp.

We should be able to eliminate the orbit by just having a speed toward the target instead of seperate xy velocities.

Var speed=0

Distance(sprite.x,Sprite.y,mouse.x,mouse.y) > (speed^2)/(2*100)
--- add 100*dt to speed
Else
--- subtract 100*dt from speed

Every tick
--- Sprite: move speed*dt pixels at angle angle(self.x,self.y,mouse.x,mouse.y)

That should be closer. A bit more work could be done on the slowing down bit. Like instead instead of just using 100 as the decceleration we could calculate the required deceleration based on the remaining distance and speed.
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Fri Mar 03, 2017 8:48 pm

B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Fri Mar 03, 2017 9:52 pm

Ty 4 the experiments.
B
33
S
18
G
27
Posts: 2,436
Reputation: 20,336

Post » Fri Mar 03, 2017 11:39 pm

@R0j0hound Those are some really neat examples. I've learnt a lot. The steering example feels super smooth.

I'm still not there yet as I have to optimize it for touch input. A tap on screen still needs an acceleration as well. The deceleration is not the big issue, it's more the acceleration. As you can see here on this screengrab from you steering curve tapping screen or rapidly moving target to a new position.

Image

This is how it behaves on rapidly changing target, which is what i need to smooth. So combining all of your awesome earlier examples there might be a solution.

I tried a similar approach using bullet behaviour and a condition from one of your earlier examples. Bullet behaviour has a built in acceleration which i'm trying to replicate in events.

Your first link for this solution was the closest so far, but it was behaving a bit weird, and overshot target and started to orbit. I need to dampen the deceleration somehow
viewtopic.php?f=147&t=163491&p=989820&hilit=Stopping+distance#p989820

here's a link to a capx with that approach.
https://dl.dropboxusercontent.com/u/20560446/Scirra/smoothchase.capxv

Thanks a lot for your help, I feel I'm nearly there.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Sat Mar 04, 2017 3:19 am

I see it looks like the acceleration is instant with your test, mine was pretty fast but it wasn't instant. It can be made to have smooth acceleration I just need to fiddle with it a bit more I think. I'll see if I can look at your capx and fiddle with my examples this weekend sometime.
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Sat Mar 04, 2017 7:33 pm

Thanks @R0j0hound . @newt @99Instances2Go for your input and ideas. I think i managed to solve it finally. Or at least as close as I could.

Speed and acceleration is based on distance now, and it works great with touch taps and clicks also. If you click somewhere it will accelerate towards the distance based max speed, then slow down after it passed that threshold.

Updated capx if you want to take a look at how I solved it.
https://dl.dropboxusercontent.com/u/20560446/Scirra/smoothchase.capx

sprite turns blue when accelerating and red when decelerating.
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Fri Mar 31, 2017 12:31 am

All of the example links are dead :( I'm facing the same issue as well, would anyone be kind to reupload it? @R0j0hound , @tunepunk
B
28
S
8
G
1
Posts: 19
Reputation: 2,245

Post » Fri Mar 31, 2017 12:55 pm

RanTH wrote:All of the example links are dead :( I'm facing the same issue as well, would anyone be kind to reupload it? @R0j0hound , @tunepunk


Hi, here's a link to my latest solution.
http://tunepunk.com/share/smoothchase.capx
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests