- Home /
Move a Rigidbody2d After Collision
I have a big problem here. I have object A in between and I have one BoxColider2d to my left and another BoxColider2d to my right. When my object moves from left to Right, i want it to revert back left after it collides with the Right BoxColider2d.
Code used to move from left to right: (Correct me if i Need another code)
public float speed;
GetComponent().AddForce(new Vector2(speed, 0));
Just like an enemy in the game Mario that moves left-Right continuously, i need the same. Below the two enemys collide with the wall and change direction. How do i achieve this? I want them to move automatically and not using Input.
Kindly help Folks :)
Your answer
Follow this Question
Related Questions
Box and circle Collider doesn't work 1 Answer
2D Colliders aren't actually touching but they're behaving like they do? 0 Answers
How to change settings to a rigidbody when adding it to a gamobject? 2 Answers
Player is not moving 0 Answers
How can I make diagonal collisions work with raycasts from a boxcollider? (3D, C#) 0 Answers