Jump to content


Photo

Changing (joystick) aim speed? [SOLVED]


  • Please log in to reply
8 replies to this topic

#1 zeninja

zeninja

    GMC Member

  • New Member
  • 32 posts
  • Version:GM8

Posted 11 July 2012 - 08:57 PM

I'm working on a top down shooter using lasers and would like to make it so that when the player is shooting, they can not aim as quickly. I've got the game working on 360 controllers using sinazxinput and was wondering if there's a way to make it so that instead of aiming exactly where the joystick is pointing, you can implement an artificial lag behind it so that where the laser is shooting is behind where the player is currently aiming.

Edited by zeninja, 11 July 2012 - 09:06 PM.

  • 0

#2 ZingZingZap

ZingZingZap

    GMC Member

  • GMC Member
  • 88 posts
  • Version:GM:Studio

Posted 11 July 2012 - 09:21 PM

To make the laser lag, in the step event, make the object move towards the site, using move towards D&D function: set the speed slower than the sight moves.
Code something like : move_towards_point(x.target,y.target,0.5)
Where x.target is to be replaced with targets object name or other variable that holds it's current location, same for y.target.
Adjust 0.5 to the speed you require.

Zzz

Edited by ZingZingZap, 11 July 2012 - 09:29 PM.

  • 0

#3 zeninja

zeninja

    GMC Member

  • New Member
  • 32 posts
  • Version:GM8

Posted 12 July 2012 - 05:29 AM

To make the laser lag, in the step event, make the object move towards the site, using move towards D&D function: set the speed slower than the sight moves.
Code something like : move_towards_point(x.target,y.target,0.5)
Where x.target is to be replaced with targets object name or other variable that holds it's current location, same for y.target.
Adjust 0.5 to the speed you require.

Zzz


The thing is, since I'm using lasers and not bullets, it just draws a line straight from the player to the point. At the moment I'm using the move to contact Dragndrop function and then draw_line in the draw step. Is there a way to convert this to the move towards function?
  • 0

#4 zeninja

zeninja

    GMC Member

  • New Member
  • 32 posts
  • Version:GM8

Posted 12 July 2012 - 05:29 AM

To make the laser lag, in the step event, make the object move towards the site, using move towards D&D function: set the speed slower than the sight moves.
Code something like : move_towards_point(x.target,y.target,0.5)
Where x.target is to be replaced with targets object name or other variable that holds it's current location, same for y.target.
Adjust 0.5 to the speed you require.

Zzz


The thing is, since I'm using lasers and not bullets, it just draws a line straight from the player to the point. At the moment I'm using the move to contact Dragndrop function and then draw_line in the draw step. Is there a way to convert this to the move towards function?
  • 0

#5 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5400 posts
  • Version:GM:Studio

Posted 12 July 2012 - 07:06 AM

http://www.gmlscript...ngle_difference

using that script you can change the angle like so:

aim_dir = point_direction(x,y,mouse_x,mouse_y)
diff = angle_difference( direction, aim_dir ) // might need to change the order on those 2

direction += min( abs(diff) , 5) * sign(diff) // where 5 will be the max turnrate

  • 0

#6 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14395 posts
  • Version:GM:Studio

Posted 12 July 2012 - 06:24 PM

new position += (indicated position-old position)/lag
  • 0

#7 zeninja

zeninja

    GMC Member

  • New Member
  • 32 posts
  • Version:GM8

Posted 15 July 2012 - 06:23 AM

I'm not sure why but it seems like the use of the direction variable is messing with the player's movement. The laser is shooting according to where the player is moving and facing rather than allowing the player to move in one direction and shoot in another. Any ideas on why this might be happening?
  • 0

#8 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14395 posts
  • Version:GM:Studio

Posted 15 July 2012 - 06:47 AM

You have to properly dissociate the direction of the moving and the facing angle.

direction is where you are moving towards (when the speed is set)

image_angle is your facing direction
  • 0

#9 zeninja

zeninja

    GMC Member

  • New Member
  • 32 posts
  • Version:GM8

Posted 15 July 2012 - 09:14 PM

Yup, looks like that did it. Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users