Top-Down Shooter.. bullets help -SOLVED-

SanctionSanction Member Posts: 9
edited July 2013 in Working with GS (Mac)
Hey guys I'm Matt.. I'm new to GameSalad!! Love it..

I need to some help getting my bullets to project in the direction of my mouse.. & then I need them disappear.
It seems to work but I also have the screen following the Player so it messes up when then screen moves and the spell stops at that location and not getting destroyed.. can anyone help me out or move me on the right direction?

this is what i got.. if you can read it

Actors: Player, Bullet
Game Attributes:
Attack_Type: 0 int
Mouse_X: 0 real
Mouse_Y: 0 real

Player:
---------------
On Key "space" is DOWN
DO:
change attribute,
Set: "game.Mouse_X" To: "game.mouse.pos"
change attribute,
Set: "game.Mouse_Y" To: "game.mouse.pos"

if "game.Attack_Type" = "0" {
DO:
Spawn Actor: "fireball" Place: "in back of actor"
In Direction: "0" Relative to: "actor"
from Pos: "0", "0" Relative to: "actor"
}
---------------

Bullet:
---------------
change attrivute,
Set: "self.MouseX" To: "game.Mouse_X"
change attrivute,
Set: "self.MouseY" To: "game.Mouse_Y"

move to,
move To: "self.MouseX", "self.MouseY" Relative to: "actor"
at a speed of: "300" []run to completion
_________________

Comments

  • zoopezoope Member Posts: 210
  • SanctionSanction Member Posts: 9
    @zoope Thanks for that 1st video that was a big problem..

    I just need to figure out how to destroy the bullets.. or would it be better to recycle them?
    Pros and Cons of Destroying Bullets or Recycle Bullets anyone?
  • zoopezoope Member Posts: 210
    You can destroy bullets on collision with the target actor, or destroy them with a timer...

    Spawning should not cause problems unless you go overboard with it.
  • SanctionSanction Member Posts: 9
    How do I keep the bullet going past the position of the mouse? so it will collide with a wall or an enemy? because the bullet goes to the mouse X&Y position but then stops and sits there eating away my memory.
  • zoopezoope Member Posts: 210
    It would be best to move the bullet using the move behaviour in that case instead of moveto.

    You will need to record the angle between the bullet and the mouse position using a variable, lets call it mouseAngle.

    When mouse is down change attribute mouseAngle to
    vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )

    This will move the bullet precisely at the mouse position.

    You can add another behaviour on whichever actor is spawning the bullet to spawn it only when mouse position is down.

    So when the bullet is spawned it will get the angle in which it needs to move.

    Hope that helps.
  • SanctionSanction Member Posts: 9
    edited July 2013
    Thanks so much! after just a few minuets I got it working for the most part..

    FIXED - multiple bullets going towards the mouse angle..
    (added bullet its own attribute "MouseAngle")

    FIXED - when I leave the screen initial area it messed all up..
    (added CamX and CamY to vectorToangle formula!)
    vectorToangle(CamX + game.mouse.x - self.position.x, CamY + game.mouse.y - self.position.y)

  • zoopezoope Member Posts: 210
    How are you moving the camera at the moment?
  • SanctionSanction Member Posts: 9
    Control Camera on Player
Sign In or Register to comment.