[Resolved]Create an assistance to control a ship, possible ?

0 favourites
From the Asset Store
AAA Game Character Ship AI
$14.50 USD
50% off
Game Character Ship AI voiceover sound library provides you with more than 370+ sound files.
  • Hello all,

    I come to post here because I need help for a game that I develop. This game would be an MMO in space with a ship but a rather realistic physics. I took care of physics but I would like to create as aids to help control the ship, the goal would be to compare the angle towards which it is moving and the angle towards which it is oriented to restore the ship.

    Is it possible ?

    Thanks in advance and good evening,

    Jules

    PS : Please pardon my English because I'm a French

  • Do you mean you want to rotate the ship?

    Here is how you get movement angle:

    angle(0,0, Ship.Physics.VelocityX, Ship.Physics.VelocityY)

    You can slowly change ship angle until it reaches this angle, for example:

    Ship -> Set angle to anglelerp(self.Angle, angle(0,0, Self.Physics.VelocityX, Self.Physics.VelocityY), dt/2)

    It's not recommended to change angle for physics objects directly, so you can try to do the same with physics actions like "set angular velocity".

    And, of course you should only adjust the angle when player is not controlling the ship.

  • Good evening,

    Thank you for your quick reply.

    I do not want to re-orient the ship, but engage side reactors.

    Thanks for the formula to use to calculate the orientation to which it moves.

    And again thanks for the formula to slow down the rotation, it will be of great use to me. I will apply everything you told me, and I will give you news of the game.

    A big thank you again

    Sincerely and good evening,

    Jules

    PS: Forgive my English because I am French

  • Good evening,

    I return this message because I cannot stabilize the ship.

    The problem is that the value to which it is turning is from 0 to 360, and the value to which it is pointing is -180 to 180. And so when I compare these two values to restore the vessel with the side reactors, I can't.

    Do you know the method to equalize these two values? If yes, how ?

    Thank you in advance,

    Regards,

    Jules

  • Yeah, angles in C2 can be confusing. Say, angles -30, 330 and 690 are actually the same angle.

    If you use system expressions anglediff, anglelerp, anglerotate etc. - they take care of conversions for you.

    For example anglediff(-29, 690) = 1

    If you still can't fix it, please share your capx or a screenshot of your code.

  • Good evening,

    Thank you very much for your quick answer !

    Indeed, I need a lot of help because I cannot make this damn comparison ... I sent the screenshots of my events. My goal would be to make a comparison of two values to operate or not side reactors. These two values are the angle at which he is heading and the angle at which he is turning. Do you know the method to do this ? I tried +180 at the angle where he is heading, but the problem is that the 0 is not in the same place ...

    Could you help me ?

    A big thank you in advance.

    Very cordially,

    Good night

    Jules

    Images :

    Variables : dropbox.com/s/0qwx9a3m6ce798t/Screen2.PNG

    Comparaisons : dropbox.com/s/v83kutpq5kyn1c4/Screen1.PNG

  • Julot135

    First of all, why are you multiplying the angle of movement by 2? Angle and speed are completely different things. Angle could be 0 and speed could be 1000, you can't derive one from another.

    Second, applying force correctly may be difficult and it will set the ship off-course.

    I suggest you use angular velocity - it only rotates the ship without changing its direction of movement.

    You can still animate ship reactors (thrusters) if you want.

    See this demo:

    https://www.dropbox.com/s/j2v54a17gshr4 ... .capx?dl=0

  • Good evening,

    For the multiplication, it is that I took the picture between the moment when I put the *2 and the moment when I realized that it didn't serve anything. For the name AngleSpeed, I know that this name has no reports, it's just for me.

    For the reactors, I would try ...

    However, I cannot open your project :O

    Thank you for your help

  • Why can't you open my project?

    If you have an older version of Construct2, rename my capx file to zip, unpack to a folder, open .caproj file in Notepad and edit this line:

    <saved-with-version>24400</saved-with-version>

    You can change it to 23900 or whatever version you have.

  • Thanks a lot for the advice ! I have the r245 version. So I managed to open the file but it's not really what I would like ... I would prefer with a real physics, in fact I would simply compare the angle where he is heading and the angle where he is orient, and operate side reactors. Thank you for this example.

  • Try Construct 3

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

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

    Good evening,

    I made a montage to make you understand what I want to do:

    dropbox.com/s/okzkl3u14yzsol ... l.mp4?dl=0

  • So you need to set movement direction to ship's angle, not the other way around!

    Sorry, I misunderstood you.

    Here is another demo, I think it's what you want:

    https://www.dropbox.com/s/9rjbrl0wpc1zz ... .capx?dl=0

  • And if you don't actually need Physics, you can do this without any behaviors at all:

    https://www.dropbox.com/s/1mtx5omp7f314 ... .capx?dl=0

    It's based on R0J0hound's example from this post:

    spaceship-movement_t198897

    So all kudos to him!

  • Hello,

    So your SpaceVaisseau2 example is exactly what I want!

    I would not be able to thank you, everything works perfectly!

    And no problem not to have understood me, it's me who wasn't explicit enough

    In addition, I adapted it easily and quickly with your comments.

    Soon, I'll give you a little demo of the game, because with your help, I can continue to advance this game !

    Thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you ... and thank you !

    And thank you again for answering me and being super efficient for me.

    I wish you an Happy Christmas and an Happy New Year.

    Very good day,

    Jules

  • Hey Jules, no worries!

    Glad I could help. Merry Christmas to you too!

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