Top down question

GingerBGamesGingerBGames Member Posts: 390
edited November -1 in Working with GS (Mac)
Hello GS'ers,

I'm making a top down shooter game, and I'm having a difficult time accomplishing a task. I'm using a D-pad and a button. The D-pad utilizes all 8 directions, and the button if for firing the weapon. My actors start position is facing right. When I push the fire button, the gun flare and bullet come out in the front of the gun, great! However, when I go to any other direction (each with is proper character image, such when touch, change image) the bullets and the flare are still facing the right side of the character. How do I get it to be at the tip of my weapon no matter what direction i'm traveling? Any help would be appreciated. Thank you.

Comments

  • GingerBGamesGingerBGames Member Posts: 390
    Maybe someone knows of a template I can use as an example?
  • reddotincreddotinc Member Posts: 653
    What direction have you got set for the bullet to be fired? As the actor will always remain its constant orientation, it will always fire to the right.

    You need to have rules to say when position = north (for example) fire at 0 degrees

    Hope that helps.

    // Red Dot Inc
  • Rob2Rob2 Member Posts: 2,402
    how are you doing your bullets and flare?
  • specialist_3specialist_3 Member Posts: 121
    This is what worked for me...

    Lets assume you have 2 Actors. One is you Gun and the other is your bullet.
    Assume your gun is pointing north.

    Inside the Rule which says when you press SPACE,
    You would spawn your bullet in direction 90 degrees relative to Actor, and set position X=0 and Y= some value which near tip of the gun. Position is also relative to Actor. Suppose your gun image is of Size 30 by 30, the the Y value will be about 25 to make it appear the bullet is coming through the barrel. Layer order (back of actor)

    Now, In your Bullet Actor, set MOVE behavior direction to 0, relative to actor and any speed u want. Additive.

    Let me know if this works.
  • specialist_3specialist_3 Member Posts: 121
    One more thing, in case u want your gun to rotate and therefore shoot in right direction, you would have a Global Variable call Bullet Rotation. You would set this to the value of the gun's rotation which will be self.rotation. so it will be

    Gun Actor,
    Change attribute game.bullet.angle to self.rotation

    Then inside your bullet actor, you set self.rotation to game.bullet.angle.
  • specialist_3specialist_3 Member Posts: 121
    Sorry...not bullet rotation...bullet angle
  • GingerBGamesGingerBGames Member Posts: 390
    I will give these a try and let you all know, thank you for your help.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I thought you could just put 0 relative to ACTOR in the spawn behavior that is in the main player actor. That's always worked for me.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    or create a game angle attribute (game.Angle)

    In each d-pad button have a rule that says when touch is pressed change game.Angle to (insert the proper angle for each direction).

    Then in the bullet spawner use game.angle (relative to scene this time)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    or just use codemonkeys joystick demo - it's great!
  • GingerBGamesGingerBGames Member Posts: 390
    Again thank you for the ideas, i've tried them both, and no luck, they still only spawn to the right side of the actor, no matter what way i'm traveling.
Sign In or Register to comment.