How to make an actor shoot toward mouse click.

Hello all. I'm a game salad noob and I was wondering if there is a way to make an actor shoot toward a single mouse click. I am trying to make a space shooter where missiles spawn from a planet and shoot asteroids and the like. I can get the missiles to move towards every click, but I would like each missile to only move toward the location of the mouse click that also spawned said missile. Also, is there a way to make the missile rotate toward the click? Thanks

Comments

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

    @zombychicken said:
    Hello all. I'm a game salad noob and I was wondering if there is a way to make an actor shoot toward a single mouse click.

    Use the Move To behaviour.

    First store where the mouse has been clicked into two attributes, X and Y, then use the Move To behaviour to move to this X and Y location.

    I am trying to make a space shooter where missiles spawn from a planet and shoot asteroids and the like. I can get the missiles to move towards every click, but I would like each missile to only move toward the location of the mouse click that also spawned said missile.

    Here's a quick demo file:

    Link: https://www.mediafire.com/?2cdm33c72jtp2tp

    Also, is there a way to make the missile rotate toward the click? Thanks

    Change self.rotation to:

    vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Give something like this a try:

Sign In or Register to comment.