movink
This commit is contained in:
@@ -106,7 +106,7 @@ namespace Game
|
||||
return hitInfos;
|
||||
}
|
||||
|
||||
private bool SlideMove(Vector3 start, ref Vector3 velocity)
|
||||
private bool SlideMove(Vector3 start, bool stepUp, ref Vector3 velocity)
|
||||
{
|
||||
// PM_SlideMove
|
||||
/*
|
||||
@@ -185,6 +185,15 @@ namespace Game
|
||||
private const float stopspeed = 100f;
|
||||
private const float accelerationGround = 10f;
|
||||
private const float jumpVelocity = 270f;
|
||||
|
||||
private const float maxAirSpeed = 320f;
|
||||
private const float maxAirStrafeSpeed = 320f; //Q2+
|
||||
private const float airAcceleration = 0.4f * 0f; //Q2+
|
||||
private const float airStopAcceleration = 2.5f * 0f; //Q2+
|
||||
private const float airStrafeAcceleration = 70f * 0f; //CPM?
|
||||
private const float strafeAcceleration = 10f; //QW
|
||||
private const float airControl = 0f; //CPM
|
||||
|
||||
private bool jumped = false;
|
||||
|
||||
public override void OnFixedUpdate()
|
||||
@@ -196,7 +205,7 @@ namespace Game
|
||||
var moveDirection = rootTrans.TransformDirection(inputDirection);
|
||||
|
||||
Vector3 wishVelocity = Vector3.Zero;
|
||||
if (!Console.IsOpen && !inputDirection.IsZero)
|
||||
if (!inputDirection.IsZero)
|
||||
{
|
||||
//move = moveDirection.Normalized * MoveSpeed * Time.DeltaTime / (1.0f/Time.PhysicsFPS);
|
||||
inputDirection = moveDirection.Normalized * MoveSpeed;
|
||||
@@ -252,31 +261,62 @@ namespace Game
|
||||
currentVelocity *= newspeed / currentSpeed;
|
||||
}
|
||||
|
||||
// ground acceleration
|
||||
bool stepUp = false;
|
||||
|
||||
if (onGround) // ground acceleration
|
||||
{
|
||||
float currentSpeed = Vector3.Dot(currentVelocity, wishVelocity.Normalized);
|
||||
ApplyAcceleration(wishVelocity.Normalized, wishVelocity.Length, 0f, accelerationGround);
|
||||
/*float currentSpeed = Vector3.Dot(currentVelocity, wishVelocity.Normalized);
|
||||
float addSpeed = wishVelocity.Length - currentSpeed;
|
||||
|
||||
|
||||
if (addSpeed > 0)
|
||||
{
|
||||
float accelSpeed = 12f * wishVelocity.Length * Time.DeltaTime;
|
||||
float accelSpeed = accelerationGround * wishVelocity.Length * Time.DeltaTime;
|
||||
if (accelSpeed > addSpeed)
|
||||
accelSpeed = addSpeed;
|
||||
|
||||
currentVelocity += accelSpeed * wishVelocity.Normalized;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else // air acceleration
|
||||
{
|
||||
var wishspeed = wishVelocity.Length;
|
||||
if (wishspeed > maxAirSpeed)
|
||||
wishspeed = maxAirSpeed;
|
||||
|
||||
if (strafeAcceleration != 0)
|
||||
ApplyAcceleration(wishVelocity.Normalized, wishspeed, maxAirStrafeSpeed, strafeAcceleration);
|
||||
|
||||
stepUp = true;
|
||||
}
|
||||
|
||||
if (!onGround)
|
||||
currentVelocity += Physics.Gravity * Time.DeltaTime;
|
||||
|
||||
bool blocked2 = SlideMove(rigidBody.Position, ref currentVelocity);
|
||||
bool blocked2 = SlideMove(rigidBody.Position, stepUp, ref currentVelocity);
|
||||
if (currentVelocity.Length > 0.0f)
|
||||
rigidBody.Position += currentVelocity * Time.DeltaTime;
|
||||
}
|
||||
|
||||
void ApplyAcceleration(Vector3 wishDir, float wishspeed, float maxWishspeed, float acceleration)
|
||||
{
|
||||
float wishspeedOrig = wishspeed;
|
||||
if (wishspeed > 0f && wishspeed > maxWishspeed)
|
||||
wishspeed = maxWishspeed;
|
||||
|
||||
float currentSpeed = Vector3.Dot(currentVelocity, wishDir);
|
||||
float addSpeed = wishspeed - currentSpeed;
|
||||
|
||||
if (addSpeed > 0)
|
||||
{
|
||||
float accelSpeed = acceleration * wishspeedOrig * Time.DeltaTime;
|
||||
if (accelSpeed > addSpeed)
|
||||
accelSpeed = addSpeed;
|
||||
|
||||
currentVelocity += accelSpeed * wishDir;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
float xAxis = InputManager.GetAxis("Mouse X");
|
||||
|
||||
Reference in New Issue
Block a user