Movement

Hey. Please bear with me because I'm new to this. I'm creating a gamesalad project in windows for university. Basically its a top down game and I need help with actor movement.
The game background will be dark and when I click the button down on the mouse it will create a circle of light like a torch. If the torch is over an actor, I want the actor to follow the torch/mouse when it is dragged but only while the actor is in the torch area. If the mouse is depressed or the torch light is moved away from the actor, I want the actor to continue on its previous commanded path until it hits a wall. Any help would be greatly appreciated.

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @firemaplegames‌ has a flashlight demo you might like (attached).

    The basic idea for the movement would be:

    When actor collides with [torch actor]
         [store current direction as angle attribute]
         [follow mouse]
    Otherwise
         [move in stored direction]

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

  • ULTIMATEGMXULTIMATEGMX Member Posts: 2
    Thanks for your help. Im still having some trouble. How do I store the current direction?
    Also I couldnt open the zip attachment. Im on windows and I think this was a mac file. Appreciate your help.
  • ULTIMATEGMXULTIMATEGMX Member Posts: 2
    Also how do i get an actor to spawn when the mouse button is down but then the same actor destroys when the mouse is released?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Thanks for your help. Im still having some trouble. How do I store the current direction?
    Change Attribute game.direction (angle attribute) to vectorToAngle(self.Motion.Linear Velocity.X,self.Motion.Linear Velocity.Y).
    Also I couldnt open the zip attachment. Im on windows and I think this was a mac file.
    Check out the video in the Video tab here: http://gshelper.com/shop/free-templates-and-tutorials/mac-to-windows-template-conversion-gamesalad-tutorial.
    Also how do i get an actor to spawn when the mouse button is down but then the same actor destroys when the mouse is released?
    This can be quite tricky to code. To be clear, you want the player to click the mouse and have an actor spawn and then when the player releases the mouse, have that same actor be destroyed? The only way I've been successful in doing that is to have a rule in another actor that handles a mouse up event. See attached demo (click white square to spawn blue square, then release to destroy it).

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

Sign In or Register to comment.