Jump to content


Photo

aiming in 2d offset


  • Please log in to reply
2 replies to this topic

#1 Listro

Listro

    GMC Member

  • New Member
  • 14 posts
  • Version:GM8

Posted 28 February 2012 - 06:27 PM

Ive been having this problem for awhile but was just hopping it would go away as i finished the game but it didnt. It seems that if you aim close to the character it doesnt aim correctly. If you aim far away from the character is works fine but if you try to shoot a short distance in front of you then the bullet goes off in a different direction which isnt good. Could it be where the origin of the player is or how the bullet spawns?


the game
  • 0

#2 Listro

Listro

    GMC Member

  • New Member
  • 14 posts
  • Version:GM8

Posted 28 February 2012 - 07:58 PM

Anyone Know?
  • 0

#3 Sev

Sev

    GMC Member

  • New Member
  • 12 posts
  • Version:GM:Studio

Posted 29 February 2012 - 12:16 PM

It has to do with how the Move Towards Point works it takes the x, and y of the calling object (in this case the bullet) and checks in what direction the second x, y point is from it (in this case mouse_x, mouse_y) and doesn't take ANYTHING else into account so I'm sure if you think about it you can figure out where the issue comes from, especially since you practically hit it on the head already...

how the bullet spawns


Anyhow, a fix or at least a way to make it work how I assume you want it to is in your obj_man where the bullets are created drop the + 50 and - 50 offset from the X's (but Keep the Y's offset), and in the create of the bullets AFTER the Move Towards Point, put in
if (mouse_x > obj_man.x)
{
    x += 50;
};

if (mouse_x < obj_man.x)
{
    x -= 50;
};

to reapply that offset.

It's hard for me to explain how this works, aside from understanding what's posted above. but I tested it and it seems to work how I assume you want it to.

Hope this Helps :smile:

Edited by Sev, 29 February 2012 - 12:25 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users