So i am trying to make this geometry type game and just finished making a start menu not done though. The scene loads fine and everything works but when you start the game the player don’t jump when you click but when you open the player’s inspector everything starts working again. I have the script jump whenever you click and it used to work fine but now I keep have pause the game go to the inspector and then its normal. Can someone help also I can describe if someone is willing to help. my scene manager script is fine but I think there is something wrong with the player script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
public GameObject Player;
private float time = 0.0f;
private bool isMoving = false;
private bool isJumpPressed = false;
public float Boost;
public float L;
public float F;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
isJumpPressed = Input.GetMouseButtonDown(0);
}
void FixedUpdate()
{
if (isJumpPressed)
{
// the cube is going to move upwards in 10 units per second
rb.velocity = new Vector3(0, Boost, 0);
isMoving = true;
Debug.Log("jump");
}
if (isMoving)
{
// when the cube has moved for 10 seconds, report its position
time = time + Time.fixedDeltaTime;
if (time > 10.0f)
{
Debug.Log(gameObject.transform.position.y + " : " + time);
time = 0.0f;
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Obstacle")
{
Destroy(Player);
}
}
}