G(
using System.Collections.Generic;
using UnityEngine;
public class player_movment_V2 : MonoBehaviour
{
public Rigidbody rb;
public float up_jump_force;
public float forward_jump_force;
public CapsuleCollider col;
public LayerMask groundLayers;
private void Start()
{
col = GetComponent<CapsuleCollider>();
}
void Update()
{
if (IsGrounded() && Input.GetKeyDown(KeyCode.Mouse0))
{
this.rb.AddForce(transform.up * up_jump_force, ForceMode.Impulse);
this.rb.AddForce(transform.forward * forward_jump_force, ForceMode.Impulse);
}
if (Input.GetKeyDown(KeyCode.D))
{
this.transform.Rotate(0, 90, 0, Space.Self);
}
if (Input.GetKeyDown(KeyCode.A))
{
this.transform.Rotate(0, -90, 0, Space.Self);
}
}
private bool IsGrounded()
{
return Physics.CheckCapsule(col.bounds.center, new Vector3(col.bounds.center.x, col.bounds.min.y, col.bounds.center.z), col.radius * .9f, groundLayers);
}
}
