Help with shooting at mouse on platformer!

I need help solving a problem in my game. My game has an actor controlled by the WASD keys and runs around on platforms shooting enemies. I have another actor constrained to it that swivels around using the "vectotToAngle(mouse position x-self position x, mouse position y-self position y)". {It obviously was put in the proper format} It works out fine, when I use the mouse button to shoot, the little bullet flies towards it.
Here is the problem: Lets say the actor moves 20 units to the right, 20 units up. The launcher thinks the mouse is where it was back when I started the game, -20, -20 from the player. This screws up the aiming, causing it to be wayyyyy off.

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    Well, I guess I'd use a Display Text behavior to watch the value of the mouse position x & y and the actor position and see if they are in fact different. Then you'll have to go through your rules (the ones you've mentioned sound pretty straight forward) to see what's causing the discrepancy.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Are you using the actor's self.position.X and self.position.Y for the destination of the bullet actor? What does your spawn actor behavior look like (especially the x/y values)? How are you making the bullet move and what does that behavior look like?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • CerealBoxerCerealBoxer Member Posts: 13
    1. If by "Destination of the bullet actor" you mean where it spawns, yes.
      2/3. When I click the mouse, the actor spawns in front of actor and relative to actor. Everything is set to 0. The bullet goes in direction 0 at a speed of 700 relative to the actor in an additive way.

    I really do appreciate your help and dang is this frustrating!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2015

    Okay, so you're spawning the bullet actor on top of the spawner, which is fine. What direction are you spawning the bullet?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • CerealBoxerCerealBoxer Member Posts: 13

    It spawns in whatever direction the spawner is pointing at

  • CerealBoxerCerealBoxer Member Posts: 13

    I know the actor position and the mouse position are different. The actor just has to look AT the mouse position and shoot at it, not be on it!

Sign In or Register to comment.