Answer the question
In order to leave comments, you need to log in
The player passes through the walls, what to do?
Here is my player movement script (Android game):
public class Player_AD : MonoBehaviour
{
public float speed;
public float ADspeed;
public GameObject player;
public Rigidbody2D rb;
private void Start()
{
rb = GetComponent();
}
void FixedUpdate()
{
if (Input.touchCount > 0 )
{
float deltaPosX = Input.GetTouch(0).deltaPosition.x;
rb.velocity = new Vector2(deltaPosX * Time.deltaTime* speed, rb.velocity.y);
}
}
}
I forgot to say! The player still sticks to the walls. Gave Physics 2D matereal with zero friction, and everything sticks smoothly.
Here is the link to the game (You will understand better if you look for yourself):
https://play.google.com/store/apps/details?id=com....
Answer the question
In order to leave comments, you need to log in
1. What does Input do in FixedUpdate?
2. What does the documentation say about Rigidbody.velocity?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question