private void FixedUpdate() { Latching(); if (latched) { Ray ray = new Ray(transform.position + (transform.up * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal")).normalized, transform.forward); Debug.DrawRay(ray.origin, ray.direction, Color.red, 2); if (Physics.Raycast(ray, out surface, 5f, motor.discludePlayer)) { Vector3 norm = surface.normal; Vector3 c = Quaternion.AngleAxis(90, Vector3.right) * norm; Vector3 r = Quaternion.AngleAxis(-90, Vector3.up) * norm; Debug.DrawRay(surface.point, c, Color.blue); transform.up = Vector3.Lerp(transform.up, c, .5f); motor.AddVelocity(transform.up * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal"), 1.7f); motor.FinalMovementCalculation(1f); } } }
private void FinalPlayerMovement() { if (J) { motor.JumpR(true); } motor.JumpR(false); motor.AddVelocity(movementVect + gravity, 1); motor.FinalMovementCalculation(1); Debug.DrawRay(transform.position, transform.forward, Color.blue, 0.05f); }
private void Update() { if (isUnderControl) { Vector3 gravity = motor.Gravity(gravityPower); Vector3 input = motor.GainAxisInput(movementSpeed, false); motor.Jump(true); motor.Jump(false); motor.AddVelocity(input + gravity, 1); motor.FinalMovementCalculation(1); Debug.DrawRay(transform.position, transform.forward, Color.blue, 0.05f); } }