- Home /
Player stops moving upon collision
I have a 2D scene setup I have a sprite cube which is my Player and when it collides with another cube it's move stops.
Player has a box collider & Rigidbody2D.
Obstacle has a box collider.
PlayerScript
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerScript : MonoBehaviour {
public float speed;
private Rigidbody2D rb2D;
// Use this for initialization
void Start () {
rb2D = GetComponent<Rigidbody2D>();
rb2D.velocity = new Vector2(speed, 0);
}
// Update is called once per frame
void Update () {
}
}
Comment