There is my problem :
i have 1 little ghost who have à velocity of 5 and 1 game object with the Camera with a speed of 5 to
but when the ghost is on the ground he is slower than the Camera and i can’t explain it?
Script of the Ghost:
public class PlayerController : MonoBehaviour {
Vector2 velocity = Vector2.zero;
public float _jump = 10f;
private bool isGrounded = false;
public static float _velocityX;
int touch;
public float start;
public Transform groundCheck;
public float groundCheckSize;
public LayerMask ItsGround;
// Use this for initialization
void Start () {
}
void FixedUpdate()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckSize, ItsGround);
}
// Update is called once per frame
void Update () {
start = Timer.t;
if (start < 0)
{
_velocityX = 0f;
}
else {
_velocityX = 5f;
GetComponent<Rigidbody2D>().velocity = new Vector2(_velocityX, 0);
if (Input.touchCount >= 1 && isGrounded == true)
{
GetComponent<Rigidbody2D>().velocity = new Vector2(_velocityX, _jump);
Debug.Log(Input.GetTouch(0).position);
}
_velocityX = _velocityX * 1.01f;
}
}
Script of the Camera:
public class Speed : MonoBehaviour {
// Use this for initialization
private float velocityX;
void Start () {
}
// Update is called once per frame
void Update () {
velocityX = PlayerController._velocityX;
GetComponent<Rigidbody2D>().velocity = new Vector2(velocityX, 0);
}
}
Thank you.