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

0 favourites
  • 7 posts
From the Asset Store
Have you ever dreamed of playing in a Speedball game or tournament?
  • For now I have this

    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

  • 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:

    VelocityX = cos(angle(0, 0, self.Physics.VelocityX, self.Physics.VelocityY)) * maxSpeed
    VelocityY = sin(angle(0, 0, self.Physics.VelocityX, self.Physics.VelocityY)) * maxSpeed[/code:3fkmkwlh]
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • For me the most efficient way to prevent physics from slowing down my game has been not to use physics..

  • I'm way beyond that Thank you all.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)