Skip to content

Commit

Permalink
More messing with MoveAndSlide
Browse files Browse the repository at this point in the history
  • Loading branch information
copygirl committed Jul 2, 2018
1 parent 5cae93c commit f31a786
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions Level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ disabled = false

[node name="Player" parent="." index="1" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
collision/safe_margin = 0.1
_sections_unfolded = [ "Axis Lock", "Transform", "collision" ]

13 changes: 8 additions & 5 deletions Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Player : KinematicBody
private Vector3 _velocity = Vector3.Zero;

public float MouseSensitivity { get; set; } = 0.2F;
public float Gravity { get; set; } = -9.8F;
public float Gravity { get; set; } = -19.8F;
public float MaxMoveSpeed { get; set; } = 20.0F;
public float MoveAcceleration { get; set; } = -4.5F;
public float MoveDeacceleration { get; set; } = -16.0F;
Expand Down Expand Up @@ -41,13 +41,16 @@ public override void _PhysicsProcess(float delta)
// var lookVector = _camera.GetGlobalTransform();
// movementVector.Rotated(_rotation.Rotation.y);

GD.Print($"Floor: { IsOnFloor() }, Wall: { IsOnWall() }, Ceil: { IsOnCeiling() }");

if (Input.IsActionJustPressed("move_jump") && IsOnFloor())
_velocity.y = JumpVelocity;
// if (Input.IsActionJustPressed("move_jump") && IsOnFloor())
// _velocity.y = JumpVelocity;

var before = IsOnFloor();
_velocity = MoveAndSlide(_velocity, Vector3.Up, floorMaxAngle: Mathf.Deg2Rad(MaxSlopeAngle));
// GD.Print($"Velocity: { _velocity }");
var after = IsOnFloor();
GD.Print($"Before: { before }, After: { after }");
// Just jump automatically if either call to IsOnFloor returned true.
if (before || after) _velocity.y = JumpVelocity;
}

public override void _UnhandledInput(InputEvent @event)
Expand Down

0 comments on commit f31a786

Please sign in to comment.