I can probably help, but not with the limited information here. What are you actually trying to do?
[QUOTE=Willox;49229930]I can probably help, but not with the limited information here. What are you actually trying to do?[/QUOTE]
im trying to set a players z velocity
[QUOTE=MaccyD;49229942]im trying to set a players z velocity[/QUOTE]
When a console command is ran? When a key is pressed?
I sound like an ass, but there's a difference between the two. Chances are you're running in to [url=wiki.garrysmod.com/page/Prediction]prediction[/url] errors.
[QUOTE=Willox;49229956]When a console command is ran? When a key is pressed?
I sound like an ass, but there's a difference between the two. Chances are you're running in to [url=wiki.garrysmod.com/page/Prediction]prediction[/url] errors.[/QUOTE]
when v is pressed im setting their z velocity to 300
[editline]2nd December 2015[/editline]
[QUOTE=Willox;49229956]When a console command is ran? When a key is pressed?
I sound like an ass, but there's a difference between the two. Chances are you're running in to [url=wiki.garrysmod.com/page/Prediction]prediction[/url] errors.[/QUOTE]
the only thing i dont like is how smooth it is
Instead of suddenly setting the velocity to 300, he wants it to smoothly increase (from 0-300 over seconds)
[QUOTE=Coffeee;49229981]Instead of suddenly setting the velocity to 300, he wants it to smoothly increase (from 0-300 over seconds)[/QUOTE]
yes, im currently trying out the LERP
There's a couple of things you're asking for:
Vector Quantity,
Magnitude (Speed),
and Acceleration
Acceleration is the increase of a current [I]Vector-Quantity[/I].
[code]
local plyVector = ply:GetVelocity( ); local magnitude = plyVector:Length( );
if (magnitude < 500 ) then // If the acceleration peaks beyond 500, it'll stop adding velocity.
ply:SetVelocity( plyVector + Vector( 0, 0, 50 ))
end
[/code]
Acceleration is 50, going up.
use a shared setupmove hook, already told you that
[QUOTE=EthanTheGreat;49230051]:words:[/QUOTE]
When an object is moving, you can take various measurements about the motion of the object.
Measurements that only have a magnitude (i.e. length) are scalar quantities.
Measurements that have a magnitude and direction are vector quantities.
You can measure the positions of an object as time passes. The distance between the points, when linked together, is a scalar quantity and is called the 'distance,' which does not specify any direction (i.e. it says that an object travelled X units in total). However, the difference between the final and initial positions (i.e. finalPos - initialPos) is a vector quantity and is called the displacement of an object. This vector quantity specifies a distance and a direction, (i.e. it says that an object went X units in Y direction)
The change in the distance an object travels with respect to time (i.e. distance/time) is the speed of the object and is a scalar quantity that (thus) does not specify a direction.
The change in the displacement of an object with respect to time, however, is the velocity of an object, and is a vector quantity that specifies a direction. (i.e. the object is moving X units per unit-time in Y direction)
The change in the velocity of an object respect to time is its acceleration, and is a vector quantity. It tells you that the object's velocity changed by X amount per unit-time in the Y direction.
Your use of terminology was a bit confusing there. I hope this helped clear up whatever you meant in your post.
OP wants to accelerate his player to a specific velocity when a key is pressed.
Using equations of constant acceleration:
[CODE]
-- we know:
-- - initial velocity
-- - final velocity
-- - time for change in velocity to occur
-- so,
-- v = u + a * t
-- where v = final velocity, u = initial velocity, a = acceleration and t= time for the change in velocity to occur
-- rearranging the equation,
-- a = (v - u) / t
local timeToAccelerate = 1--second
local intendedVelocity = 300--units upwards
local initialVelocity = ply:GetVelocity().z
local acceleration = (intendedVelocity - initialVelocity) / timeToAccelerate
-- as an example (if you were sticking to Tick)
-- now, all you have to do is, at every tick (which is called every engine.TickInterval() seconds), increment the velocity by acceleration * engine.TickInterval() units
[/CODE]
Sorry, you need to Log In to post a reply to this thread.