Ask here your questions to get help using GDevelop.
By AnimatedG
#62618 Hi all,

I'm new to Gdevelop and will appreciate some help regarding the direction facing of sprites/objects

I have an object of a space ship and added to the ship event
"add force (angle)"
For direction i set it as : ship.Direction()

It works but for some reason it's flying backwards.
I'm thinking the default direction is set to it's rear. Is there any way to re-set the default direction of the sprite/object?

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

One more question.

Currently it is moving at a constantly +5 pixels per (sec?)

Is there a way to limit the speed?

i'm trying to use:
"Compare the speed when speed >= to 15 "
But not sure what action to use to limit it



Any help will be much appreciated. Thanks :)
User avatar
By Lizard-13
#62623 You can't change the default direction, which is facing to the right, so you have two options:
* Edit the images and flip them so they face to the right
* In every event you get the direction of the ship, add a +180 to the angle to counteract the effect:
Code: Select allAdd a force to the ship, with angle: Ship.Direction() + 180, and length: 5 px/s

I recommend to fix the images, otherwise you'll have to modify every action related to angles :twisted:

If the ship moves constantly at 5 px/s, then its speed is already limited, sorry I don't understand the problem :)
By AnimatedG
#62629 Hi Lizard-13,

Thanks for the help :)

The ship image i used was from the default resource library.
It's default direction (the cockpit) is pointing to the right.

However for some reason it is flying backwards...

Will try a custom image to see if it works correctly

Update: Tried a custom image and it works fine.

----------------------------------------------------------------------------------------------------------------

I'm trying for Asteroid kind of ship controls

After adding force(angle), at length: 5px/s with Dampening:1
The speed keeps keeps increasing per sec which is fine. But how do i limit the speed to say 20/s?

I'm trying the event: Object->Movement->Speed
Overall speed of ship >= 20
But what do i use for the action?

Thanks :)
User avatar
By Lizard-13
#62631
The ship image i used was from the default resource library.
It's default direction (the cockpit) is pointing to the right.
However for some reason it is flying backwards...
Will try a custom image to see if it works correctly
Update: Tried a custom image and it works fine.

Weird, the image should not have any effect in the force direction...

After adding force(angle), at length: 5px/s with Dampening:1
The speed keeps keeps increasing per sec which is fine. But how do i limit the speed to say 20/s?

Ok, so the speed is not constant, I get it. If you set Damping = 1 the force will be stand forever, then you add a new force that will stand forever and so on. This way the forces are added and the total effect will be applied to the ship, this is good for an acceleration process but then you want to limit the ship speed (it reminds me when I tried to do a Star-Control-like ship movement system), a nice way to do it:
* If the thrust button is pressed, add forces to the ship with damping = 1, the ship will accelerate.
* Check if the length of the ship "net force"/average force is greater than 20
* If it's greater than 20, save the ship force angle in a variable with Ship.ForceAngle(), then stop the ship with the "Stop the object" action, and add a force to the ship with force = 20 and angle = saved angle variable

Do you get it? If the ship speed is greater than the limit, replace the ship current forces with an unique force of length = limit and angle = previous average force angle :)
By AnimatedG
#62692 Hi Lizard-13,

If it's greater than 20, save the ship force angle in a variable with Ship.ForceAngle(), then stop the ship with the "Stop the object" action, and add a force to the ship with force = 20 and angle = saved angle variable


Tried this but my ship ends up stopping at speed 20 and accelerates from 0 again.

What could i be doing wrong?