GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Actor Shooting - Movement and Idle

Hey everyone! New guy here. I'm attempting to add the ability to shoot to my actor. So far I've successfully made him shoot when moving and jumping left and right, but he won't fire when he's idle.

Since there is no key press or mouse input when idle how do I set this up? Basically, I want him to have MegaMan functionality when it comes to shooting.

How can I make the game recognize when the actor is facing left and idle - to shoot left; and then when the actor is facing right and idle - to shoot right?

Any help is appreciated. Thanks!

Best Answer

Answers

  • tatiangtatiang Posts: 11,699Member, Sous Chef, PRO, Senior Sous-Chef

    Are you using different images for left and right facing or are you changing the actor's flip horizontal attribute? You can set a rule condition for either of these methods (e.g. If self.Image=left.png).

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

  • DessekDessek Posts: 14Member
    edited January 2015

    I'm using a flip at the moment. Do I need to embed the rule anywhere specific? Or should it be a new one? Thanks for the response!

    Also, I'm using animations for my left and right movement, but I have an idle animation as well. So a sequence of .pngs

  • tatiangtatiang Posts: 11,699Member, Sous Chef, PRO, Senior Sous-Chef
    edited January 2015

    No, don't embed the rule if you want it always to trigger. Just do If attribute self.Graphics.Flip Horizontally is true then [rule for shooting to the left].

    For example, you might have an Every 1 second timer that spawns a bullet to the left.

    Edit: I just tried something that requires no rule. Create an Integer attribute called self.FlipNum and Constrain Attribute self.FlipNum to self.Graphics.Flip Horizontally. That will convert the boolean to either 0 or 1. Then, in the Spawn Actor behavior (inside a timer) for the bullet, put self.FlipNum in the direction field, relative to actor. You don't have to do it this way but it does simplify the rules if all you're doing is auto-fire all the time.

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

  • DessekDessek Posts: 14Member

    Interesting. I basically want the same functionality as MegaMan lvl 1. A projectile to shoot when I press a key, in the direction I'm facing, when I'm jumping, and if I'm idle.

    I'll give it a shot when I can get back home. Thanks for your time!

  • DessekDessek Posts: 14Member

    Ah, I see! That sounds very simple. I'll give it a go when I get home. Thanks for your help! The whole "which way is my character facing in game" was confusing me. Couldn't figure out how to make that happen.

Sign In or Register to comment.