My snake movement seems laging, what to do?

Get help using Construct 2

Post » Mon Jan 26, 2015 6:48 pm

Here's the file

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


After a couple of days of trials and errors I figure out how to create a simple snake movement. But something is not correct with the snake bodies. Something is lagging.

Anyone can figure out why?
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Mon Jan 26, 2015 8:47 pm

It seem when the frame rate goes lower from 45, this lagging movement start to show. Giving the effect of the bodies are left behind.
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Mon Jan 26, 2015 9:15 pm

>@ekajuan Hm, try to pin them, position only, maybe that helps... there are somme issues similar to that here:

viewtopic.php?f=151&t=119846

viewtopic.php?f=151&t=122834

might be related to my issue, the second on. Ashley noted already, that there is an issue with the rounding engine. Try to take that out.
B
8
S
3
Posts: 197
Reputation: 1,207

Post » Mon Jan 26, 2015 9:18 pm

Also I would put the origin points not in the center, but where you want to have the joint between the body-parts. then it rotates around that. Otherwise you rotation, and set the position at the same time, cause the rotation center is off. That might cause the delay too.

Like a chain, the joints are not in the middle, but at each end of the nods (or always the one in front in your case), thus causing the chain effect. Better to use that as rotation center, I am quite sure!
B
8
S
3
Posts: 197
Reputation: 1,207

Post » Tue Jan 27, 2015 6:18 am

This basic premise of this snake movement design is to leave trail x and y position and the angle.
Each of the body parts picks the last trail and angle left by of its previous head/body. In this case 15 trails away before the body parts start to pick up.

The data is recorded in 3D array.
Each level (z) is assigned for the head and each body part.
x,y as you may guess to record the x and y position and angle of each instance.

Since the data is recorded in every tick and the frame rate can go up and down, my guess is, the trail data is not always recorded at the same pace.

My prediction is if I can insert the data in timely manner and not get influenced by the frame rate I probably could solve the problem.

But then again, even if I add the wait for x seconds... before inserting the data, it does't help. Or maybe I did it wrongly.

Round Engine.
Since I don't use rounding engine, probably the problem is not there.

Pinning
I can't still get my head to simulate that. But I have seen the example of chain in the examples file. The movement is a bit different than what I have in mind.

But I will try it maybe there's a way to utilize it.
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Wed Jan 28, 2015 4:08 pm

>@ekajuan
MultipleChoice wrote:Also I would put the origin points not in the center, but where you want to have the joint between the body-parts. then it rotates around that. Otherwise you rotation, and set the position at the same time, cause the rotation center is off. That might cause the delay too.

Like a chain, the joints are not in the middle, but at each end of the nods (or always the one in front in your case), thus causing the chain effect. Better to use that as rotation center, I am quite sure!



Still you can try that, no matter how you model movement itself. Even a snail consists of backbone-joints with this mechanics, def. better, you simulate that right.
As far as Pinning goes, I meant: You can also pin position only, and detect/calculate the angle for the right behavior. Of course rope style etc. is not what you need. A snake has muscles in each part of its body, producing rather sine-waves when moving, than pulling itself along, like paralyzed. Sure that's not gonna work ;)

But you got that part right, I'm just saying, you could rework the joint-points, anyhow you solve positioning and angles.

And yes, you do round: abs(round(Snake.Angle-Snake.old_angle)) and round(Snake.Angle) in your file...
B
8
S
3
Posts: 197
Reputation: 1,207


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], brunopalermo, David181 and 9 guests