The object keeps flipping and I cant use freeze rotation help pls
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovementScript : MonoBehaviour
{
private const bool f = false;
private const bool t = true;
public Rigidbody rb;
public float Speed;
public float JumpForce;
bool IsGrounded;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float XMove = Input.GetAxisRaw("Horizontal");
float YMove = Input.GetAxisRaw("Vertical");
rb.velocity = new Vector3(XMove, rb.velocity.y, YMove);
if (Input.GetKey(KeyCode.Space) && IsGrounded)
{
rb.velocity = Vector3.up * JumpForce * Time.fixedDeltaTime;
}
}
private void OnCollisionStay(Collision collision)
{
if (collision.collider.gameObject.tag == "Ground" )
{
IsGrounded = t;
}
else
{
IsGrounded = false;
}
}
}