if (move) // player is moving or strafing
velocity += 0.002 * 32;
else
velocity -= 0.002 * 32;
if (velocity > 1.0) velocity = 1.0;
if (velocity < 0.0) velocity = 0.0;
// x delta and z_delta are already computed according to
// y and x axis of mouse look
// finally the velocity is applied:
x_delta *= velocity;
z_delta *= velocity;
// set camera
camera[0] += x_delta;
camera[2] += z_delta;
Horizontal Velocity for First Person Shooter
hi, i have tried to incorporate a horizontal velocity in my movement code, where i use only one value for both x and z:
the problem is that the acceleration and decceleration is not working constant, sometimes it is faster, then slower, or even there is no velocity at all or i must turn around the axis so it will work again....
the source code is as follows:
Hmm. What FPS are you running? If you call this once a frame, you''ll be at full velocity in 16 frames. If you''re running at, say, 75 fps, that''s zero to full speed in 2 tenths of a second. Shouldn''t you be multiplying by a time delta somwhere in there?
thankx, but x_delta and z_delta are multiplied by the time delta between each frame, this should be right i think?
quote:Original post by Gammastrahler
thankx, but x_delta and z_delta are multiplied by the time delta between each frame, this should be right i think?
Nope. You''re correcting your velocity for time, but not your acceleration. You need to use the time delta in your velocity += and -= lines.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement