Top down question
GingerBGames
Member Posts: 390
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.
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
You need to have rules to say when position = north (for example) fire at 0 degrees
Hope that helps.
// Red Dot Inc
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.
Gun Actor,
Change attribute game.bullet.angle to self.rotation
Then inside your bullet actor, you set self.rotation to game.bullet.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)