# Physic Spaceship with Speedlimit

Get help using Construct 2

### » Fri Nov 23, 2012 2:35 pm

I want to make a Spaceship with Physic and give it a speedlimit:

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 youGameForger2012-12-09 11:49:01
B
4
S
1
G
1
Posts: 49
Reputation: 997

### » Sun Dec 02, 2012 8:18 pm

And this is my attempt:

Spaceship (Physic) Set Velosity

X Component:
sin(angle(0,0,Spaceship.Physics.VelocityX+sin(Spaceship.Angle)*Spaceship.Acceleration*dt,
Spaceship.Physics.VelocityY-cos(Spaceship.Angle)*Spaceship.Acceleration*dt))*
distance(0,0,Spaceship.Physics.VelocityX,Spaceship.Physics.VelocityY)

Y Component:
-cos(angle(0,0,Spaceship.Physics.VelocityX+sin(Spaceship.Angle)*Spaceship.Acceleration*dt,
Spaceship.Physics.VelocityY-cos(Spaceship.Angle)*Spaceship.Acceleration*dt))*
distance(0,0,Spaceship.Physics.VelocityX,Spaceship.Physics.VelocityY)

Can anyone help me with the math?GameForger2012-12-09 11:44:55
B
4
S
1
G
1
Posts: 49
Reputation: 997

bump
B
4
S
1
G
1
Posts: 49
Reputation: 997

### » Thu Dec 06, 2012 5:19 pm

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.
B
30
S
10
G
7
Posts: 416
Reputation: 7,234

### » Thu Dec 06, 2012 11:48 pm

No I want the Physic for bounce off and stuff. It's really just a math problem I can't put my finger on.
B
4
S
1
G
1
Posts: 49
Reputation: 997

### » Fri Dec 07, 2012 2:20 am

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.
B
30
S
10
G
7
Posts: 416
Reputation: 7,234

### » Fri Dec 07, 2012 2:32 am

@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 !
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

### » Fri Dec 07, 2012 2:42 am

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 ...
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

### » Fri Dec 07, 2012 5:03 am

Whiteclaw is right it messes everything up. And its really just the math, the script works fine (when you toggle the maximum capping of )
B
4
S
1
G
1
Posts: 49
Reputation: 997

### » Sun Dec 09, 2012 2:08 am

Can anyone take a look at the math?
B
4
S
1
G
1
Posts: 49
Reputation: 997

Next