Hi,
my gamepad controls apply axis-speed like this:
Gamepad.Axis(0,0) * Player.CurrentSpeed * dt[/code:2noza82q] I try following R0J0hounds suggestion to calculate velocityX like this: vx = speed * cos(angleOfMotion) so I calculate my directional speed like this [code:2noza82q]Gamepad.Axis(0,0) * Player.CurrentSpeed * dt * cos(angle(0,0,Gamepad.Axis(0,0),Gamepad.Axis(0,1)))[/code:2noza82q] However when I use this formula in the Predicitve Aim formula from this thread my baddies miscalculate the angle to hit me when shooting at me. Using 8direction vectorX and Y for keyboard controls it seems to work great btw ... I'm guessing that i'm not getting the directional speeds correctly, but the syntax seems beyond me. Can anyone help?
I'm not clear on what you're doing, but I think your formulas are off.
If you're just moving with events and the joystick directly controls the speed do this:
vx=Gamepad.Axis(0,0) * MaxSpeed vy=Gamepad.Axis(0,1) * MaxSpeed x= x+vx*dt y= y+vy*dt[/code:vtyzv8xa] If instead you want some acceleration when using the joystick do this: [code:vtyzv8xa]vx = vx + Gamepad.Axis(0,0) * acceleration*dt vy = vy + Gamepad.Axis(0,1) * acceleration*dt x= x+vx*dt y= y+vy*dt[/code:vtyzv8xa] or if you also want a max speed do this: [code:vtyzv8xa]vx = vx + Gamepad.Axis(0,0) * acceleration*dt vy = vy + Gamepad.Axis(0,1) * acceleration*dt speed = distance(0,0,vx,vy) if speed > maxSpeed { vx = vx*maxSpeed/speed vy = vy*maxSpeed/speed } x= x+vx*dt y= y+vy*dt[/code:vtyzv8xa]
Develop games in your browser. Powerful, performant & highly capable.
R0J0hound Alright, thanks a ton! It seems to work.
For future reference or if you care to double check, this what it looks like:
Wasn't sure where else the delta time needed to appear, but this seems to do as i intended (from a first glance)