Autorotation AI problem

I've been trying to get a pirate ship to sail after a players' ship in a game I'm creating. Currently, the pirate ship is moving to and rotating towards the players' ship, but it seems that after a couple of seconds rotating and moving to the player, the pirate ship just simply stops rotating or moving to the player but instead sails off in a straight line into the edge of the map.

I have the pirate ship set to move to game.PlayerX+100 and game.PlayerY+100, and then he rotates to game.PlayerRotation+60. These are all simply loose behaviours not in any rules because I want the enemies to do this constantly but I seems that they don't like doing it constantly...

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    A behavior outside of any rule will run ONCE. That means that when the scene begins, the move and rotate behaviors you have in place will check game.playerX, game.playerY, and game.PlayerRotation and set their expression values accordingly. For example, if the player starts at x=400 and then moves to x=500, the pirate ship will start out moving toward x=400 and continue moving toward that point.

    What you need is to put those behaviors inside of an every 0 seconds timer. That will constrain the expression values to the CURRENT values of the game attributes you are referencing.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • mystic 2628mystic 2628 Member Posts: 45
    Goddamn. You're a helpful person. Rotation is working properly now, but in the process of doing that, I've noticed that I can't add a real "sailing" movement to the pirate ship. While my ship can only move forward and rotate, the pirate ship can move sidewards towards me. I have a feeling this has something to do with velocity or drag, but I've got no idea what to do with them.
Sign In or Register to comment.