Physics - variable speed limits

0 favourites
  • 15 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi everyone. I hope those of you with a greater understanding of math than I have can help me with this issue.

    I have a top-down space shooter type game. I'm using custom physics-based movement to propel the ship. What I'm struggling with is the following:

    I have two max speeds set for my ship, VarTotalMaxSpeed and VarAfterburnerMaxSpeed, set to 120 and 240 respectively. I've got all the motion working quite well except for one little snag: While I want to limit the afterburner usage with limited fuel (not implemented in my example file), I want my player to always have the ability to manoeuvre with the basic thrusters, but due to the way I've set up my events, when the player is going between the speeds 120 and 240, they can only use their afterburners.

    Essentially what I want is a way for the player to use the regular thrusters at that speed, but only to slow down the ship, by flipping it in the opposite direction of travel and pressing the up button. Activating the regular thrusters would have no effect if the player continued in the same direction.

    capx

    What I'd like to accomplish:

    <img src="https://dl.dropbox.com/u/14522925/ExampleImage.jpg" border="0">

    Thanks in advance!

  • Still struggling with this problem. Is there anyone who can help me?

  • Yeah ... There's not a lot of people on the forum these days , I struggle too :(

    So ... You see the Forward and Reverse events ? Remove the "* dt" ...

    I think this makes the acceleration so little thus making it un-noticeable

  • I don't think they would help you if you installed 3rd party plugins, they prefer to open .capx without third party plugin

  • Thanks for pointing that out, I forgot that I had any third-party plugins installed, and I didn't realise that a capx requires those plugins even if they're not used.

    I've re-uploaded the file to its original location. If anyone has any advice for me, I'd really appreciate it!

    Whiteclaws, thanks, but that has no effect on this problem. Forward isn't activating at all between the speeds of 120-240 because of the conditions I've set up, but that's the only effective way I know to limit the regular forward speed, which I need to do one way or another (hoping the "another" part is what someone can help me with).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Whiteclaws

    "Yeah ... There's not a lot of people on the forum these days , I struggle too :("

    We all benefit from rich forum participation, everyone has something to teach as well as learn. But you dear Whiteclaws have probably ran off more visitors than we will ever know about. So think about your comment above, and think about some of the things you say, and ask yourself "would I like to be treated that way?" I doubt it.

  • GeometriX, I did try to help not long after you created this thread, but it required the gravitation plugin, which I couldn't be bothered to search, download and install at the time. So, yeah, Joannesalfa is right, the plugin probably deterred a lot of people from helping out. I did install the plugin last night, but got distracted and forgot to check your capx doh!

    When I first ran it, it was stuck in a loop and crashed my browser... you might want to disable that WHILE event first. I'll let you know how I get on now that's fixed ;p

  • Ah, damn, I forgot about that plugin, too :/

    Sorry procrastinator, I've removed that as well. The broken while event as well. Must've been left over from some testing I was doing.

  • Whiteclaws

    "Yeah ... There's not a lot of people on the forum these days , I struggle too :("

    We all benefit from rich forum participation, everyone has something to teach as well as learn. But you dear Whiteclaws have probably ran off more visitors than we will ever know about. So think about your comment above, and think about some of the things you say, and ask yourself "would I like to be treated that way?" I doubt it.

    val <img src="smileys/smiley1.gif" border="0" align="middle" /> You noticed too.

  • GeometriX, no worries. I recognised the "stuck in a loop" grey box from stuff I was doing last night ;p

  • If you calculate what the speed will be after applying the impulse, then you can compare the current speed with the calculated speed.

    If either of these is true then apply the force:

    +calculated speed<max speed
    
    +calculated speed>=max speed
    +calculated speed<current speed

    To calculate the speed take the same value used for applying impulse and do this:

    vx= self.Physics.VelocityX+IMPULSE/self.Physics.Mass*cos(self.Angle)

    vy= self.Physics.VelocityY+IMPULSE/self.Physics.Mass*sin(self.Angle)

    calculated speed= distance(0,0,vx,vy)

    I made my own capx to figure out a solution so here it is for a working example:

    http://dl.dropbox.com/u/5426011/examples16/spaceship.capx

  • ^ that's exactly what I was going to say! (yeah right) ;)

  • R0J0hound, you're a legend. Thanks mate, that worked perfectly. Also managed to solve my crude workaround that required linear damping on the regular thrusters, so cheers!

  • Val , Yeah , But I was here for more than a lot of time !

    So ... You see ...

  • Whiteclaws

    No Kiddo,

    Looks like you don't see.

    I'm outta this thread.

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