Need help with placing DT for custom movement

Get help using Construct 2

Post » Fri Dec 16, 2016 4:50 pm

Hi all,

I'm having some issues with my project. I'm fairly sure that it's dt related, but i can't figure out where to put, or how to put it. The problem is probably that my game runs at 30 fps or lower on my mobile device, which makes the player movement look slowmotion while everything else is running normal speed. But the game runs @ 60 fps on my laptop. This is strange because they both have nearly the same specs. My Phone is huawei Y6 (2gb ram) (quad core), laptop is Medion akoya E2215T (2gb ram) (quad core). on both devices my cpu uses around 40%, 50 at it's highest.
But since i don't know the GPU specs of both, im guessing it might be related to that.

I've did alot of research about optimizing your game and did about all of them...Still can't figure it out.
I've changed sprite sizes to fit accordingly of what they should be on the layers.
I do not use any physics at all.
I do use alot of sprites, but they are not big and around 90% do not need heavy calculation or every tick events.
All sprites not on layout are properly destroyed, and only created when needed.

That's just a few i can recall, but i did more.
However, my event sheet is a long one, but i need everything that is in there. Already cleaned it as much as i could.

Alright i'll show how my movement works.

Movement
Image

Aiming and shooting

Image

Layout view of aim and movesticks, with move and aim rings aswell
Image

So my guess is, there needs to be a dt somewhere. Because on the laptop the movement is perfect (60fps), but on Phone slowmotion (30fps). I should also note that on iPhone 6s it worked really smooth aswell, did not do a debug test, but im sure it was around 60fps. I preview on wifi to my Phone, and sometimes intel xdk. Both show same performance though.

Thanks for any help in advance.

- Grapjas
B
3
Posts: 5
Reputation: 200

Post » Fri Dec 16, 2016 5:21 pm

dt is a measure of time in second per frame.

In your scenario, dist is a measure of speed in pixels per frame. At 60fps, you'd get a movement of dist * 60 pixels per second. If that's the speed you aim for everyone to get, whatever their framerate, then you should simply use :
Code: Select all
Move dist * 60 * dt
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Fri Dec 16, 2016 5:56 pm

Thank you for your fast reply. I will test this in a bit.
B
3
Posts: 5
Reputation: 200

Post » Fri Dec 16, 2016 6:14 pm

I failed to mention something. Dist is calculated by an event.

Every tick
Image

So i guess thats where the hard part comes in. Or maybe not, but i don't know the solution.
Dist is calculated by the distance the movestick has from movering's center, devided by 12. Clamp makes the limits 0 to 5. I did /12 because when you have the stick around the visual moving ring, you are at full speed (dist 5).

I did movement like this so that you can move very precisely (slower or faster obviously). i tried move dist *dt. which makes the player move extremely slow.
B
3
Posts: 5
Reputation: 200

Post » Fri Dec 16, 2016 7:12 pm

dist*dt would make the player move at the maximum speed of 5 pixels per second, which is quite slow to say the least. That's why multiplying by 60 beforehand is necessary so everyone playing would have the player move at 300 pixels per second. (Roughly equivalent to not using dt and moving by 5 pixels per tick at 60fps)
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Fri Dec 16, 2016 7:37 pm

Magistross wrote:dist*dt would make the player move at the maximum speed of 5 pixels per second, which is quite slow to say the least. That's why multiplying by 60 beforehand is necessary so everyone playing would have the player move at 300 pixels per second. (Roughly equivalent to not using dt and moving by 5 pixels per tick at 60fps)


You're a champ, i misunderstood you in your first post. i thought *60 *dt would set a single movement speed, rather than having the precise movement. It works excactly how i need it to now, your code worked perfectly. Thank you.

One more question though, how do i give rep? :D

Anyway this case is solved. 8-)
B
3
Posts: 5
Reputation: 200


Return to How do I....?

Who is online

Users browsing this forum: Ryan Kocourek and 12 guests