double jump stuff
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
"Transform": {
|
"Transform": {
|
||||||
"Translation": {
|
"Translation": {
|
||||||
"X": 73.19660949707031,
|
"X": 73.19660949707031,
|
||||||
"Y": 0.0,
|
"Y": -33.01502227783203,
|
||||||
"Z": -139.43125915527345
|
"Z": -139.43125915527345
|
||||||
},
|
},
|
||||||
"Orientation": {
|
"Orientation": {
|
||||||
@@ -56,6 +56,12 @@
|
|||||||
"ParentID": "51c770f24232abbb112cc98b296820d8",
|
"ParentID": "51c770f24232abbb112cc98b296820d8",
|
||||||
"V": {}
|
"V": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ID": "1b648b37406d810fecb8e1ba45a51c84",
|
||||||
|
"TypeName": "Game.CameraSpring",
|
||||||
|
"ParentID": "51c770f24232abbb112cc98b296820d8",
|
||||||
|
"V": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ID": "eb46ab96465957dc67a052bd0e2ad1e5",
|
"ID": "eb46ab96465957dc67a052bd0e2ad1e5",
|
||||||
"TypeName": "FlaxEngine.Camera",
|
"TypeName": "FlaxEngine.Camera",
|
||||||
@@ -245,6 +251,30 @@
|
|||||||
},
|
},
|
||||||
"StaticFlags": 0,
|
"StaticFlags": 0,
|
||||||
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
|
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ID": "12cd95b64f5145dcae7b28b7404ef512",
|
||||||
|
"TypeName": "FlaxEngine.StaticModel",
|
||||||
|
"ParentID": "a50f3639419a8306036ecfab7115e772",
|
||||||
|
"Name": "PlayerModel",
|
||||||
|
"Transform": {
|
||||||
|
"Scale": {
|
||||||
|
"X": 0.30000001192092898,
|
||||||
|
"Y": 0.5600000023841858,
|
||||||
|
"Z": 0.30000001192092898
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Model": "b43f0f8f4aaba3f3156896a5a22ba493",
|
||||||
|
"Buffer": {
|
||||||
|
"Entries": [
|
||||||
|
{
|
||||||
|
"Material": "a75d425f40ef7ba5df0fdb8d470e8a78",
|
||||||
|
"ShadowsMode": 3,
|
||||||
|
"Visible": true,
|
||||||
|
"ReceiveDecals": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -76,7 +76,7 @@
|
|||||||
},
|
},
|
||||||
"Control": "FlaxEngine.GUI.Label",
|
"Control": "FlaxEngine.GUI.Label",
|
||||||
"Data": {
|
"Data": {
|
||||||
"Text": "eFPS: 15 uTime: 297.4087306\nuFPS: 15 uTime: 0.00833330024033785\nrFPS: 15 rTime: 0\npFPS: 30 pTime: 0",
|
"Text": "eFPS: 118 uTime: 44.9332779\nuFPS: 120 uTime: 0.00833330024033785\nrFPS: 120 rTime: 0\npFPS: 30 pTime: 0",
|
||||||
"TextColor": {
|
"TextColor": {
|
||||||
"R": 1.0,
|
"R": 1.0,
|
||||||
"G": 1.0,
|
"G": 1.0,
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
},
|
},
|
||||||
"Offsets": {
|
"Offsets": {
|
||||||
"Left": 0.0,
|
"Left": 0.0,
|
||||||
"Right": 224.0,
|
"Right": 231.0,
|
||||||
"Top": -97.0,
|
"Top": -97.0,
|
||||||
"Bottom": 64.0
|
"Bottom": 64.0
|
||||||
},
|
},
|
||||||
@@ -237,7 +237,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ID": "5a96096947dadddc8576978ffc6ee455",
|
"ID": "5a96096947dadddc8576978ffc6ee455",
|
||||||
"TypeName": "Game.CameraSpring",
|
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
|
||||||
|
"PrefabObjectID": "1b648b37406d810fecb8e1ba45a51c84",
|
||||||
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2",
|
"ParentID": "f4ab880f47cab1ca423ce8b04f524ac2",
|
||||||
"V": {}
|
"V": {}
|
||||||
},
|
},
|
||||||
@@ -320,6 +321,17 @@
|
|||||||
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
|
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
|
||||||
"PrefabObjectID": "3932111d4c6f925a7b4a2e912307c82a",
|
"PrefabObjectID": "3932111d4c6f925a7b4a2e912307c82a",
|
||||||
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
|
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ID": "fd4a1e8447db1c20c62974aa57fc205f",
|
||||||
|
"PrefabID": "82e58c9d462fba5a0df1a599417ff684",
|
||||||
|
"PrefabObjectID": "12cd95b64f5145dcae7b28b7404ef512",
|
||||||
|
"ParentID": "59cc65774b36b4a58a274fb7b4e9d490",
|
||||||
|
"Buffer": {
|
||||||
|
"Entries": [
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -789,6 +789,9 @@ namespace Game
|
|||||||
private const float stopspeed = 100f;
|
private const float stopspeed = 100f;
|
||||||
private const float accelerationGround = 12f;
|
private const float accelerationGround = 12f;
|
||||||
private const float jumpVelocity = 270f;
|
private const float jumpVelocity = 270f;
|
||||||
|
private const float jumpBoostTime = 0.5f;
|
||||||
|
private const float jumpBoostVelocity = 100f;
|
||||||
|
private const int jumpBoostMaxJumps = 2;
|
||||||
|
|
||||||
private const float maxAirSpeed = 320f;
|
private const float maxAirSpeed = 320f;
|
||||||
private const float maxAirStrafeSpeed = 30f;
|
private const float maxAirStrafeSpeed = 30f;
|
||||||
@@ -806,6 +809,7 @@ namespace Game
|
|||||||
|
|
||||||
private bool jumped = false;
|
private bool jumped = false;
|
||||||
private float lastJumped = -1f;
|
private float lastJumped = -1f;
|
||||||
|
private int numJumps = 0;
|
||||||
private float lastLanded = -1f;
|
private float lastLanded = -1f;
|
||||||
|
|
||||||
//private Vector3 safePosition;
|
//private Vector3 safePosition;
|
||||||
@@ -850,17 +854,81 @@ namespace Game
|
|||||||
bool lastGround = onGround;
|
bool lastGround = onGround;
|
||||||
Vector3 lastVelocity = velocity;
|
Vector3 lastVelocity = velocity;
|
||||||
onGround = true;
|
onGround = true;
|
||||||
|
|
||||||
|
TraceInfo traceGround = CategorizePosition(position, ref velocity);
|
||||||
|
|
||||||
|
bool jumpAction = inputState.jumping;
|
||||||
|
|
||||||
|
if (jumped && !jumpAction)
|
||||||
|
jumped = false; // jump released
|
||||||
|
else if (jumped && Time.GameTime - lastJumped >= autoJumpTime)
|
||||||
|
jumped = false; // jump timeout
|
||||||
|
|
||||||
|
// jump
|
||||||
|
if (onGround && jumpAction && !jumped)
|
||||||
|
{
|
||||||
|
if (OnJump(traceGround, ref velocity))
|
||||||
|
{
|
||||||
|
onGround = false;
|
||||||
|
jumped = true;
|
||||||
|
lastJumped = Time.GameTime;
|
||||||
|
numJumps++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Time.GameTime - lastJumped > jumpBoostTime)
|
||||||
|
numJumps = 0;
|
||||||
|
|
||||||
|
//if (/*onGround && */lastGround != onGround)
|
||||||
|
if (onGround)
|
||||||
|
{
|
||||||
|
// ground friction
|
||||||
|
ApplyFriction(ref velocity);
|
||||||
|
|
||||||
|
// ground acceleration
|
||||||
|
ApplyAcceleration(ref velocity, wishVelocity.Normalized, wishVelocity.Length, float.MaxValue,
|
||||||
|
accelerationGround);
|
||||||
|
}
|
||||||
|
else // air movement
|
||||||
|
{
|
||||||
|
ApplyAirAcceleration(ref velocity, wishVelocity);
|
||||||
|
}
|
||||||
|
|
||||||
|
StepSlideMove(Actor, ref position, ref velocity, onGround);
|
||||||
|
|
||||||
|
|
||||||
|
TraceInfo traceGround2 = CategorizePosition(position, ref velocity);
|
||||||
|
|
||||||
|
rigidBody.Position = position;
|
||||||
|
currentVelocity = velocity;
|
||||||
|
//rigidBody.LinearVelocity = velocity;
|
||||||
|
|
||||||
|
const float landingVelocityThreshold = 120f;
|
||||||
|
const float landingHardVelocityThreshold = 500f;
|
||||||
|
if (currentVelocity.Y - lastVelocity.Y > landingVelocityThreshold)
|
||||||
|
{
|
||||||
|
if (Time.GameTime - lastJumped > 0.01)
|
||||||
|
{
|
||||||
|
bool hardLanding = currentVelocity.Y - lastVelocity.Y > landingHardVelocityThreshold;
|
||||||
|
OnLanded(currentVelocity - lastVelocity, hardLanding);
|
||||||
|
lastLanded = Time.GameTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TraceInfo CategorizePosition(Vector3 position, ref Vector3 velocity)
|
||||||
|
{
|
||||||
Vector3 groundDelta = Gravity.Normalized;//Gravity.Normalized * (collisionMargin * 2);
|
Vector3 groundDelta = Gravity.Normalized;//Gravity.Normalized * (collisionMargin * 2);
|
||||||
//if (velocity.Y < 0f)
|
//if (velocity.Y < 0f)
|
||||||
// groundDelta = Gravity.Normalized * velocity.Y * Time.DeltaTime;
|
// groundDelta = Gravity.Normalized * velocity.Y * Time.DeltaTime;
|
||||||
TraceInfo traceGround = TracePlayer(Actor, position, position + groundDelta);
|
TraceInfo traceGround = TracePlayer(Actor, position, position + groundDelta);
|
||||||
//Console.PrintDebug(1, true, "startSolid: " + traceGround.startSolid);
|
//Console.PrintDebug(1, true, "startSolid: " + traceGround.startSolid);
|
||||||
|
|
||||||
if (!traceGround.startSolid && traceGround.fraction < 1f &&
|
if (!traceGround.startSolid && traceGround.fraction < 1f &&
|
||||||
-Vector3.Dot(Gravity.Normalized, traceGround.hitNormal) < slopeNormal)
|
-Vector3.Dot(Gravity.Normalized, traceGround.hitNormal) < slopeNormal)
|
||||||
{
|
{
|
||||||
//Console.Print("slope?");
|
|
||||||
// slope
|
|
||||||
// clip velocity
|
// clip velocity
|
||||||
|
|
||||||
Vector3 bounce = groundDelta;
|
Vector3 bounce = groundDelta;
|
||||||
//Vector3 velocityProjected = Vector3.ProjectOnPlane(velocity, normal);
|
//Vector3 velocityProjected = Vector3.ProjectOnPlane(velocity, normal);
|
||||||
float backoff = Vector3.Dot(bounce, traceGround.hitNormal) * 2f;
|
float backoff = Vector3.Dot(bounce, traceGround.hitNormal) * 2f;
|
||||||
@@ -891,70 +959,38 @@ namespace Game
|
|||||||
//Console.PrintDebug(1, true, "issolid? :" + traceGround.startSolid);
|
//Console.PrintDebug(1, true, "issolid? :" + traceGround.startSolid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: snap to ground here
|
//if (onGround && !slope)
|
||||||
|
// velocity.Y = 0f;
|
||||||
|
|
||||||
bool jumpAction = inputState.jumping;
|
// TODO: snap to ground here?
|
||||||
|
return traceGround;
|
||||||
if (jumped && !jumpAction)
|
|
||||||
jumped = false; // jump released
|
|
||||||
else if (jumped && Time.GameTime - lastJumped >= autoJumpTime)
|
|
||||||
jumped = false; // jump timeout
|
|
||||||
|
|
||||||
// jump
|
|
||||||
if (onGround && jumpAction && !jumped)
|
|
||||||
{
|
|
||||||
if (OnJump(traceGround, ref velocity))
|
|
||||||
{
|
|
||||||
onGround = false;
|
|
||||||
jumped = true;
|
|
||||||
lastJumped = Time.GameTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (/*onGround && */lastGround != onGround)
|
|
||||||
if (onGround)
|
|
||||||
{
|
|
||||||
// ground friction
|
|
||||||
ApplyFriction(ref velocity);
|
|
||||||
|
|
||||||
// ground acceleration
|
|
||||||
ApplyAcceleration(ref velocity, wishVelocity.Normalized, wishVelocity.Length, float.MaxValue,
|
|
||||||
accelerationGround);
|
|
||||||
}
|
|
||||||
else // air movement
|
|
||||||
{
|
|
||||||
ApplyAirAcceleration(ref velocity, wishVelocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
StepSlideMove(Actor, ref position, ref velocity, onGround);
|
|
||||||
|
|
||||||
rigidBody.Position = position;
|
|
||||||
currentVelocity = velocity;
|
|
||||||
//rigidBody.LinearVelocity = velocity;
|
|
||||||
|
|
||||||
const float landingVelocityThreshold = 120f;
|
|
||||||
const float landingHardVelocityThreshold = 500f;
|
|
||||||
if (currentVelocity.Y - lastVelocity.Y > landingVelocityThreshold)
|
|
||||||
{
|
|
||||||
if (Time.GameTime - lastJumped > 0.01)
|
|
||||||
{
|
|
||||||
bool hardLanding = currentVelocity.Y - lastVelocity.Y > landingHardVelocityThreshold;
|
|
||||||
OnLanded(currentVelocity - lastVelocity, hardLanding);
|
|
||||||
lastLanded = Time.GameTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnJump(TraceInfo traceGround, ref Vector3 velocity)
|
private bool OnJump(TraceInfo traceGround, ref Vector3 velocity)
|
||||||
{
|
{
|
||||||
|
float jumpVel = jumpVelocity;
|
||||||
|
if (Time.GameTime - lastJumped < jumpBoostTime)
|
||||||
|
jumpVel += jumpBoostVelocity;
|
||||||
|
|
||||||
// reset velocity from gravity
|
// reset velocity from gravity
|
||||||
if (-Vector3.Dot(Gravity.Normalized, velocity) < 0 &&
|
if (-Vector3.Dot(Gravity.Normalized, velocity) < 0 &&
|
||||||
Vector3.Dot(velocity, traceGround.hitNormal) < -0.1)
|
Vector3.Dot(velocity, traceGround.hitNormal) < -0.1)
|
||||||
{
|
{
|
||||||
|
Console.Print("vel before: " + velocity.Y);
|
||||||
velocity = Vector3.ProjectOnPlane(velocity, traceGround.hitNormal);
|
velocity = Vector3.ProjectOnPlane(velocity, traceGround.hitNormal);
|
||||||
|
Console.Print("vel after: " + velocity.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
velocity += Vector3.Up * jumpVelocity;
|
velocity += Vector3.Up * jumpVel;
|
||||||
|
|
||||||
|
bool ktjump = true;
|
||||||
|
if (ktjump)
|
||||||
|
{
|
||||||
|
if (velocity.Y < jumpVel)
|
||||||
|
velocity.Y = jumpVel;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.Print("jumpvel: " + velocity.Y);
|
||||||
|
|
||||||
if (!predicting)
|
if (!predicting)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace Game
|
|||||||
public string mapPath = @"C:\dev\Goake\maps\aerowalk\aerowalk.map";
|
public string mapPath = @"C:\dev\Goake\maps\aerowalk\aerowalk.map";
|
||||||
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map";
|
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map";
|
||||||
|
|
||||||
|
public bool importLights = false;
|
||||||
|
|
||||||
Model model;
|
Model model;
|
||||||
private MaterialBase missingMaterial;
|
private MaterialBase missingMaterial;
|
||||||
|
|
||||||
@@ -300,7 +302,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
worldSpawnActor = Actor.AddChild<Actor>();
|
worldSpawnActor = Actor.AddChild<Actor>();
|
||||||
worldSpawnActor.Name = "WorldSpawn";
|
worldSpawnActor.Name = "WorldSpawn";
|
||||||
//worldSpawnActor.HideFlags |= HideFlags.DontSave;
|
worldSpawnActor.HideFlags |= HideFlags.DontSave;
|
||||||
worldSpawnActor.HideFlags |= HideFlags.DontSelect;
|
worldSpawnActor.HideFlags |= HideFlags.DontSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,6 +685,7 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle entities
|
// Handle entities
|
||||||
|
if (importLights)
|
||||||
{
|
{
|
||||||
sw.Restart();
|
sw.Restart();
|
||||||
int lightIndex = 0;
|
int lightIndex = 0;
|
||||||
@@ -696,11 +699,11 @@ namespace Game
|
|||||||
return new Vector3(float.Parse(points[0]), float.Parse(points[2]), float.Parse(points[1]));
|
return new Vector3(float.Parse(points[0]), float.Parse(points[2]), float.Parse(points[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
Color ParseColor(string origin)
|
/*Color ParseColor(string origin)
|
||||||
{
|
{
|
||||||
string[] points = origin.Split(new char[] { ' ' });
|
string[] points = origin.Split(new char[] { ' ' });
|
||||||
return new Color(float.Parse(points[0]), float.Parse(points[1]), float.Parse(points[2]));
|
return new Color(float.Parse(points[0]), float.Parse(points[1]), float.Parse(points[2]));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//Console.Print("light");
|
//Console.Print("light");
|
||||||
PointLight light = worldSpawnActor.AddChild<PointLight>();
|
PointLight light = worldSpawnActor.AddChild<PointLight>();
|
||||||
@@ -742,7 +745,7 @@ namespace Game
|
|||||||
lightIndex++;
|
lightIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Print("test: " + (new Vector2(1f,0f) == Vector2.Zero));
|
//Console.Print("test: " + (new Vector2(1f,0f) == Vector2.Zero));
|
||||||
|
|
||||||
Console.Print("light parsing time: " + sw.Elapsed.TotalMilliseconds + "ms");
|
Console.Print("light parsing time: " + sw.Elapsed.TotalMilliseconds + "ms");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user