Physic Spaceship with Speedlimit

Get help using Construct 2

Post » Mon Dec 10, 2012 1:11 am

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.Segoi2012-12-10 01:13:14
B
7
G
1
Posts: 14
Reputation: 710

Post » Mon Dec 10, 2012 9:51 pm

Can't you just set the velocity to the max_speed and let the physics behavior do the hard work for you ?
B
45
S
16
G
18
Posts: 845
Reputation: 13,673

Post » Tue Dec 11, 2012 10:05 am

@ 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

I think I messed up the angle_of_motion, but I don't know how. GameForger2012-12-11 10:08:54
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Tue Dec 11, 2012 1:50 pm

For the "tossing around", have you tried using directional impulse ? The ship would still have a limited velocity though...
B
45
S
16
G
18
Posts: 845
Reputation: 13,673

Post » Tue Dec 11, 2012 9:49 pm

The tossing works already in the game. Making the limit work well really is the problem.
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Thu Dec 13, 2012 2:29 am

I would do something like this using custom movement behaviour:

If Custom Movement Overall speed > Max speed
Set Custom movement Overall speed to Sprite.CustomMovement.Speed*0.99
B
7
G
1
Posts: 14
Reputation: 710

Post » Thu Dec 13, 2012 2:33 am

You dont have to calculate the direction, the acceleration or anything since the Custom movement speed is the final speed in the direction your sprite travels. So slowing that down when it's exceeding max speed will give you a speed limit.
B
7
G
1
Posts: 14
Reputation: 710

Post » Thu Dec 13, 2012 2:37 am

If you want to see how my ships moves you can try my demo.
https://dl.dropbox.com/u/48649374/Space%20Combat%20II%20v0.13.zip
B
7
G
1
Posts: 14
Reputation: 710

Post » Thu Dec 13, 2012 9:05 pm

The red Ship looks cool :D
But sorry it runs too slow on my machine, its an old 2.4 Ghz (1FPS or so) and the ship is off screen too fast to judge handling.
You used Construct right? ;)

I think using Custom Behavior is no option for me. Its just not interactive enough for me. I have to do all the calculations, I would have to write my own Boxed2d Physic for things that collide, no thanks

I prefer letting Physic behavior work it out with proper input and tweaking. The rotation already works really well with so little effort.


I just want the math to work right (Angle_of_Motion). I'm just not seeing the flaw, if you or anyone could help me with that, I'm all happy ^^
But thanks for your suggestions.
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Fri Dec 14, 2012 11:52 pm

+++ Update +++

I made the code more readable and changed my initial approach. I Studied some Geometry:
Polar and Cartesian Coordinates

I looked for the right way to Convert the Polar Coordinates (Angle and Force) to Cartesian Coordinates (VelocityX VelocityY). So when the Spaceship is about to exceed Max_Speed I want to get the Angle of current motion + Acceleratio * dt.
Then use that Angle and set VelocityX VelocityY with new Angle but old Speed.

Here is the CAPX
(at update_Spaceship/Apply_Input marked with comments (3x))
(Use Arrow Keys and Ctrl)

This is my approach:


Accel_Angle seems to not change at all once Max_Speed is reached

Still not sure if I picked the right formulas.
B
4
S
1
G
1
Posts: 49
Reputation: 997

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests