# Physic Spaceship with Speedlimit

0 favourites
• 24 posts
From the Asset Store
Bundle of different spaceships and a boss to make an intense spaceshooter or bullet hell game.
• I want to make a Spaceship with Physic and give it a speedlimit:

<img src="https://dl.dropbox.com/u/34146606/Question.PNG" border="0">

Accelerate:

If Velocity > Max_Speed Then

Get Angle of this Motion:

Current_X_Velocity + Sin ( ShipAngle ) * Acceleration * dt

Current_Y_Velocity - Cos ( ShipAngle ) * Acceleration * dt

Use the Angle:

Set X_Velocity: Sin (MotionAngle) * Old_Velocity

Set Y_Velocity:-Cos (MotionAngle) * Old_Velocity

Endif

Here is the capx:

CAPX

(Use Arrow Keys and Ctrl)

Hope you can help me with sin/cos and the math ;)

Thank you

• And this is my attempt:

<font size="6">Spaceship (Physic) Set Velosity</font>

<font color=magenta>X Component:</font>

<font color=blue>sin(angle(0,0,</font><font color=green>Spaceship.Physics.VelocityX</font>+<font color=red>sin(Spaceship.Angle)*Spaceship.Acceleration*dt</font>,

<font color=green>Spaceship.Physics.VelocityY</font><font color=red>-cos(Spaceship.Angle)*Spaceship.Acceleration*dt</font><font color=blue>))</font><font color=green>*

distance(0,0,Spaceship.Physics.VelocityX,Spaceship.Physics.VelocityY)</font>

<font color=magenta>Y Component:</font>

<font color=blue> -cos(angle(0,0,</font><font color=green>Spaceship.Physics.VelocityX</font>+<font color=red>sin(Spaceship.Angle)*Spaceship.Acceleration*dt</font>,

<font color=green>Spaceship.Physics.VelocityY</font><font color=red>-cos(Spaceship.Angle)*Spaceship.Acceleration*dt</font><font color=blue>))</font><font color=green>*

distance(0,0,Spaceship.Physics.VelocityX,Spaceship.Physics.VelocityY)</font>

Can anyone help me with the math?

• bump

• Why not just use the 8Way direction behavior? It has Max Speed, Acceleration, Decel? Seems like it does everything you want. Without any super fun geometry that I used to use in things like XNA.

• No I want the Physic for bounce off and stuff. It's really just a math problem I can't put my finger on.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Still not understanding why you would do this manually. 8Way direction and physics behavior would cover this right? You could set the mass/density of your ship in relation to the speed as well.

• firebelly I could be wrong , but using two behaviors in one shot would overlap the physics and cause some unusual problems ... The easy way isn't the always the best one !

• Your Script Is pretty much too complicated ... I'm sorry ! I'm only Second Grade in High School ... Didn't study cos , sin and that stuff :p !

The Only thing that I can tell you is that you made your life complicated ...

• Whiteclaw is right it messes everything up. And its really just the math, the script works fine (when you toggle the maximum capping of )

• Can anyone take a look at the math?

• Before getting grey hair with the math, have you tried the custom movement behaviour? I used it together with physics and it should work.

In my spaceship game I used Set Speed to Sprite[CustomMovement].Speed * 0.999

• so it would always slow down a little. This was in construct classic, but I believe it's the same principle.

The main idea is that the speed factor in custom movement behaviour have already made the math you're trying to do.

• Can't you just set the velocity to the max_speed and let the physics behavior do the hard work for you ?

• Segoi: I don't see how custom behavior should work this out without using the same math problem

Magistross: I could do that but I find it dissatisfying. When the ship gets a hit, say from an explosion and is tossed around, it shouldn't slow down instantly (very slow ships). I want to mix Arcade action feeling with a physical responsive world, in a way that you are still in control of the ship most of the time <img src="smileys/smiley2.gif" border="0" align="middle" />

I think I messed up the angle_of_motion, but I don't know how. <img src="smileys/smiley5.gif" border="0" align="middle" />

• For the "tossing around", have you tried using directional impulse ? The ship would still have a limited velocity though...

• The tossing works already in the game. Making the limit work well really is the problem.

• 24 posts