Shooting Left Help

Okay so I am still a noob at GS but I am getting the hang of some stuff. I have some decent mechanics going for my platformer but I am having a major challenge with getting my player to shoot left. I have tried everything I could think of and now hoping I can get some insight if anyone has a good fix. I have Linked screenshots of my shooting and moving code. The last thing that I tried was a FaceRight(boolean) on my shooting to no avail.![](image image image "")

Comments

  • jdmcneiljdmcneil Member Posts: 10

    The photos were bad in my previous line here are better links:

    Jumping Move Rules:
    http://s1.postimg.org/zdshdcfu7/Jumping_Move_Rules.png

    Regular Move Rules:
    http://s3.postimg.org/638yn2fbn/Regular_move_rules.png

    Shooting Rules:
    http://s24.postimg.org/s2bb91cp1/Shooting_rule.png

    Thanks in advance for any help I can get!

  • quantumsheepquantumsheep Member Posts: 8,188

    Try using the self motion attribute to designate left/right facing.

    I.e.

    If A is down
    And motion is >0
    Shoot right

    If A is down
    And motion is <0
    Shoot left

    Hope that helps,

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    You need to state the actual problem otherwise people can only really guess ! There are a couple of mind-readers here (and you might get lucky and one will pitch in with some suggestions), but for the rest of us you need to articulate the actual problem, saying "I am having a major challenge" could mean anything, the bullets move way too slow, the spawn but then just stop moving, they go right instead of left, they never appear at all, they appear just fine but always appear 100 pixels to the left of the actor . . etc etc (and a thousand other scenarios!) :)

  • jdmcneiljdmcneil Member Posts: 10

    @Socks said:
    You need to state the actual problem otherwise people can only really guess ! There are a couple of mind-readers here (and you might get lucky and one will pitch in with some suggestions), but for the rest of us you need to articulate the actual problem, saying "I am having a major challenge" could mean anything, the bullets move way too slow, the spawn but then just stop moving, they go right instead of left, they never appear at all, they appear just fine but always appear 100 pixels to the left of the actor . . etc etc (and a thousand other scenarios!) :)

    Socks I thought I was clear with the problem and I posted pictures of my rules. My Actor shoots fine to the right, even the hit registration works with enemy's. I just cant get him to shoot left. If I hit the left key the animation will look left and continue to look left but when I press the shoot key It will still will only shoot right.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @jdmcneil said:
    Socks I thought I was clear with the problem . . .

    Not at all, you didn't say what the issue was, just that you were having a "major challenge", which - as I say - can mean just about anything ! :o

    @jdmcneil said:
    . . . and I posted pictures of my rules.

    Without knowing what we are looking for screenshots of rules are not that helpful, you obviously know what the problem is, why not simply state it rather than have people to look through your rules and see if they can guess what the problem is, it's much faster route.

    @jdmcneil said:
    I just cant get him to shoot left. If I hit the left key the animation will look left and continue to look left but when I press the shoot key It will still will only shoot right.

    There ! That's the stuff we like to see :) up until this point no one knew that. I'll take a look later (now that I know what I'm looking for) not at my computer right now.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    In your spawn behaviour you have PlayerBullet direction set to 180 deg, this simply turns the bullet upside down (rotates it 180 deg) . . . it imparts no movement to the bullet.

    I can see you spawn a bullet, but you've not included the rules for that bullet . . . the rules for the bullet are what make it move, so it's impossible say why the bullet is behaving as it does without seeing its rules.

  • jdmcneiljdmcneil Member Posts: 10

    @Socks said:
    There ! That's the stuff we like to see :) up until this point no one knew that. I'll take a look later (now that I know what I'm looking for) not at my computer right now.

    Thanks!

    This seems like something that should be simple but I have no idea what I am doing wrong.

    The biggest thing that I want is like Megaman style, meaning when I press right he will face right and shoot right until I press left, then he stays facing left and shooting left.

  • TosanuTosanu Member, PRO Posts: 388

    My favorite trick is make the FaceRight of the player a global boolean. Then i create a local boolean in the bullet that takes the faceright boolean on spawning (Change attribute rule). You need to create the local boolean or the bullet switches direction every time you turn.

    Then the bullet checkts its Local Boolean and has its Velocity (Change attribute (linear velocity X) to match which direction it was fired in.

  • jdmcneiljdmcneil Member Posts: 10

    @Tosanu said:
    My favorite trick is make the FaceRight of the player a global boolean. Then i create a local boolean in the bullet that takes the faceright boolean on spawning (Change attribute rule). You need to create the local boolean or the bullet switches direction every time you turn.

    Then the bullet checkts its Local Boolean and has its Velocity (Change attribute (linear velocity X) to match which direction it was fired in.

    When I do the global FaceRight do I use a Constrain Attribute on the player? That way It checks for the liner velocity of X.

  • TosanuTosanu Member, PRO Posts: 388

    Honestly, I never preferred that. I built my face rule into button presses. So that when you press the button to go left, it then turns FaceRight False until such time as i hit the button to go right.

    However, I wouldnt recommend a Constrain. youd be trying to mix a boolean and an integer/real. Youre better off with a rule.

    If Motionx >0
    Change to True

    If motion X < 0
    Change to False

    You want two separate rules, no Else, because this way it doesnt get confused when you arent moving.

  • jdmcneiljdmcneil Member Posts: 10

    @Socks said:
    I can see you spawn a bullet, but you've not included the rules for that bullet . . . the rules for the bullet are what make it move, so it's impossible say why the bullet is behaving as it does without seeing its rules.

    For my bullet rules all I have is a move and a destroy when it collides with certain objects.

    Bullet Rules:

    http://s8.postimg.org/gv37nfp4l/Bullet_Rules.png

  • TosanuTosanu Member, PRO Posts: 388

    For my setup, rather than a Move, you would need to Change Attribute Velocity, just to note.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2014

    @jdmcneil‌

    In the move rule -- when you want it to go left -- change the direction to 180.

    So in the bullet actor the rule would look something like this:

    Rule:  When FaceRight is True
        Move:  Direction: 0 Speed:500
    Otherwise
        Move: Direction 180 Speed: 500
    
  • jdmcneiljdmcneil Member Posts: 10

    @Tosanu said:
    For my setup, rather than a Move, you would need to Change Attribute Velocity, just to note.

    Here is what I have on the bullet. Now the bullets just stay in place with no movement.

    http://s29.postimg.org/8w6z6be9j/Bullet_Rules.png>; @Tosanu said:

  • TosanuTosanu Member, PRO Posts: 388

    You added a "When moving" condition to the bullets. I am not certain as to why.

    Faceright needs to be copied from the global Facing boolean the player creates.

  • SocksSocks London, UK.Member Posts: 12,822

    @jdmcneil said:
    For my bullet rules all I have is a move . . .

    That's the cause of your problem, your move behaviour is moving the bullet left, so when you spawn the bullet actor it moves left . . . .

  • jdmcneiljdmcneil Member Posts: 10

    Okay I hope I am getting closer to understanding this. Right now I have a global boolean called FaceRight.

    On my player is two separate rules:

    self.Motion.Linier Velocity X > 0.0
    Change Attribute - game.FaceRight to true

    self.Motion.Linier Velocity X < 0.0
    Change Attribute - game.FaceRight to false

    On the bullet Two separate rules as well:

    game.FaceRight is true
    Change Attribute - self.Motion.Linier Velocity X to 500

    game.FaceRight is false
    Change Attribute - self.Motion.Linier Velocity X to -500

    Like this players shoot left no problem but bullet will only move right when I move right.

    Screen shots of rules:

    http://s12.postimg.org/6ivud41st/Player_Rule.png

    http://s27.postimg.org/q67ntr3r7/Bullet.png

  • TosanuTosanu Member, PRO Posts: 388

    You missed a step. Sorry, I must not have said it clearly. You dont tie the bullet's movements to game.faceright. That means every time you turn and move the bullet will change directions in mid air.

    What you need is a local attribute on the bullet, BulletFaceRight. Make the first command on the bullet Change BulletFaceRight to FaceRight, and switch the bullet rules to check that rather than the global. This basically creates a snapshot of the direction you were facing, so the bullet knows which direction it is coming from.

  • jdmcneiljdmcneil Member Posts: 10

    @Tosanu said:
    What you need is a local attribute on the bullet, BulletFaceRight.

    You have been awesome help! Makes sense now that I see it. I think I am still missing a step somewhere though. I press the shoot key it shoots left and if i start moving right it will shoot perfectly right but soon as I stop moving it will default back to shooting left wether I am looking right or left.

    http://s22.postimg.org/kwdmtzoo1/Player_Shoot.png

    http://s2.postimg.org/o3abg32u1/Bullet_Face_Right.png

  • TosanuTosanu Member, PRO Posts: 388

    This is why it still might be better to tie in the boolean with your controls. How do you control the Left and Right movement on your actor?

  • jdmcneiljdmcneil Member Posts: 10

    @Tosanu said:
    How do you control the Left and Right movement on your actor?

    Here are my move and jump Rules.

    Regular Move Rules:
    http://s28.postimg.org/djyo6lngt/Regular_Move_Rules.png

    Jump Rules:
    http://s29.postimg.org/uamwy0mwn/Jumping_Move_Rules.png

  • jdmcneiljdmcneil Member Posts: 10

    @Tosan You are an amazing help! Thank you so much, I was a little thick in catching on. I think I was trying to over complicate things. I moved my bullet movement into my walk right and walk left and now it works perfectly.

    Thanks again!

    Here is what my movement rule looks like now:

    http://s24.postimg.org/k2bo53vlx/Regular_character_movement.png

  • TosanuTosanu Member, PRO Posts: 388

    I;d love to take credit as a genius, but its just that I've been using this method repeatedly for an action platformer for the last few months, so I've gotten the hang of it. You can use those facing rules for a lot of other options now, since you've basically defined on your character which way he's "looking".

Sign In or Register to comment.