How do I limit speed of physics obj, the most efficient way

Get help using Construct 2

Post » Wed Jan 27, 2016 3:57 am

For now I have this Image

But I was wondering if there was a more efficient way to do this, that is less CPU intensive but doesn't allow for a 0.04 sec window where there's no speed limit.

The game is a space game and I'm controlling a spaceship.

Thank you
B
35
S
4
G
1
Posts: 284
Reputation: 2,576

Post » Wed Jan 27, 2016 4:16 am

Why not just remove the "Every 0.05 seconds" and let the event run every tick? Unless you have an unreal number of these spaceship objects, there shouldn't be any performance impact.

EDIT: Also, the way you're limiting the speed is... odd, and not really accurate. A more accurate way would be to set the velocity to something along these lines:
Code: Select all
VelocityX = cos(angle(0, 0, self.Physics.VelocityX, self.Physics.VelocityY)) * maxSpeed
VelocityY = sin(angle(0, 0, self.Physics.VelocityX, self.Physics.VelocityY)) * maxSpeed
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Wed Jan 27, 2016 4:34 am

@Linkman2004 First, thank you for your reply.

I'm working at the ends of performance here since it's a mobile game. So I'm really REALLY trying to push every last drop of CPU goodness. Accuracy is not extremely important in this case. There is some leeway since I made buffers in multiple ways.

Is this accurate way that you limit speed faster CPU? I'm mostly looking to optimize CPU usage, even if it's only a fraction of a difference :)

The code you provided seems more processing intensive than mine. Any ideas for something even less accurate but easier for processor?
B
35
S
4
G
1
Posts: 284
Reputation: 2,576

Post » Wed Jan 27, 2016 5:27 am

Have you actually measured performance? It seems like you're trying to prematurely optimize under the ill conceived notion that a single event is going to make a discernible difference, which only happens in extreme cases. I wouldn't worry about it.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Wed Jan 27, 2016 6:39 am

@linkman2004 Yup constantly testing on an iphone 6 in low battery mode (1/3 of CPU) and profiling in chrome to see who is the biggest culprit. Maxspeed was definitely not the culprit :) But I wanted to tweak what I can.

I really don't want the iPhone to heat up, so I keep everything to a bare minimum.
I'm running 90 objects, 40 collision check ticks, with 28mb RAM usage for a fairly complex physics game.

I'm also asking since I might want to base more onto this process later on. :)
B
35
S
4
G
1
Posts: 284
Reputation: 2,576

Post » Wed Jan 27, 2016 11:47 am

For me the most efficient way to prevent physics from slowing down my game has been not to use physics..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 27, 2016 12:42 pm

I'm way beyond that :) The core of the game is complex gravity calcs. So Can't go back on that. Never mind I guess. This will do it for now :) Thank you all.
B
35
S
4
G
1
Posts: 284
Reputation: 2,576


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests