action()
if(!client) return
if(steering)
var/a = 0
if(client.keys[controls.left]) a += 5
if(client.keys[controls.right]) a -= 5
// if you're pressing up you go forwards
if(client.keys[controls.up])
if(steering.velocity < steering.move_speed)
steering.velocity += steering.acceleration
// if you're pressing down you go backwards
else if(client.keys[controls.down])
/*
if(steering.speed > -steering.move_speed / 2)
steering.speed -= steering.acceleration
*/
if(steering.velocity > 0)
steering.velocity -= steering.acceleration
else
steering.velocity = 0
// otherwise you slow down
else
if(steering.velocity > steering.acceleration)
steering.velocity -= steering.acceleration/4
else if(steering.velocity < -steering.acceleration)
steering.velocity += steering.acceleration
else
steering.velocity = 0
angle += a
// generate a rotated icon to represent the angle that you're facing.
var/icon/I = icon(initial(steering.icon), steering.icon_state)
I.Turn(-angle)
steering.icon = I
if(steering.velocity != 0)
var/dx = round(cos(angle) * steering.velocity + 0.5)
var/dy = round(sin(angle) * steering.velocity + 0.5)
steering.pixel_move(dx, dy)
else ..()
In the vehicle mob's interact():
interact(mob/m)
m.loc=src
m.client.eye=src
m.steering = src
Prior to the update, it had the desired behavior- when the mob interacts with the vehicle, they "hop in" and start steering. Now, they "hop in" but the movement keys do nothing.
What am I doing wrong?
The only thing that'd stop the action() proc from being called is if the mob was deactivated. You can put some debug statements in, but I'm pretty sure this code is being executed.
The code works fine for me. The only problem is that I get a black screen when entering the vehicle. I had to call the mob's watch() proc instead of setting client.eye directly (ex: m.watch(src)). All of the movement code works. I would guess this means either:
1. I've made a change to the library since posting it that fixes whatever is causing this problem (seems unlikely, I haven't changed much).
2. You have other code in your project that is causing this to not work (seems less likely, considering this was working for you before the last update).