Question by
A_Angey_Baby_Duck_Named_Ben · Jun 12, 2020 at 12:18 AM ·
fpsjumpfps controller
Field ' ' is never assigned to and will always have its default value 0. Pls help me
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovement : MonoBehaviour { [SerializeField] float speed; [SerializeField] float jumpPower; [SerializeField] float raycastDistance;
private Rigidbody rb;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
Jump();
}
private bool isGrounded()
{
Debug.DrawRay(transform.position,Vector3.down * raycastDistance,Color.blue);
return Physics.Raycast(transform.position,Vector3.down,raycastDistance);
}
private void Jump()
{
if(Input.GetKeyDown(KeyCode.Space))
{
if(isGrounded())
{
rb.AddForce(0, jumpPower, 0, ForceMode.Impulse);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Error BCE0018 0 Answers
How Do I Get My Player To Move With The Block That Its On 1 Answer
Parented Object moves weirdly in FPS Standard Asset Camera 0 Answers
Y Mouse Movement without the tilting 0 Answers
,Fps Controller jumps automaticalley 0 Answers