In need of help on game

We are developing a shooting game, we want to have a character on the left side of our screen have the ability to aim and shoot enemies that are approaching from the right side of the screen. We want to develop a targeting system where you can have on screen crosshairs anywhere you point the mouse and hover over an enemy. How do you create the mouse target so that the target follows under the mouse pointer? Also how do you get a bullet (actor) to shoot in the direction of where you point the mouse, but continue to go beyond target point if there is no hit? Any and all help would be awesome. I am a Newbie with a lot of passion.

Comments

  • AppTacoAppTaco Member Posts: 125
    In order to make the crosshairs follow the mouse, simply make two constrain attributes in the "crosshair" actor. One constrains self.position.X to device.mouseposition.X and the other constrain attribute constrains self.position.Y to device.mouseposition.Y

    As for the bullets, you can make a rule in your player actor,

    When mouse button is down,
    Timer, every .5 seconds, spawn actor "bullet".

    Then in the "bullet" actor create a change velocity behavior,

    In the direction expression box put vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )

    In the speed expression box, put however fast you want your bullet to go.

    It's a bit complicated. Let me know if you have any questions. If you would like, I can whip up a template to demonstrate.
  • Thunder_ChildThunder_Child Member Posts: 2,343
    You could simply destroy actor (bullet) when collide or overlap with actor type (x). This when stop the bullet when it hits your target....also you can group many of your actors under a tag and makes it easier to write your code vs doing this for each actor.
  • SocksSocks London, UK.Member Posts: 12,822
    @pixelpowervfx

    Here's a quick demo using some of the suggestions from above:
  • pixelpowervfxpixelpowervfx Member Posts: 8
    You all are 5 stars in my book, I want to let you know I appreciate all of your efforts to help me and my students. It is great to see a productive community such as this one!
Sign In or Register to comment.