- Home /
Move until collide?
I want it so that when I press Right Arrow Key on the red tile, it moves until it hits the green tile. All of the coloured tiles have box colliders on them with the tag of "Collide"
help.png
(56.8 kB)
Comment
Answer by N-8-D-e-v · Sep 24, 2020 at 05:31 PM
RaycastHit2D hit = Physics2D.Raycast(transform.position, directionTraveling, sizeOfEachTile / 2 + aLittleNumber, otherTilesLayerMask);
where direction is transform.right if moving right, transform.up if moving up etc. And if it doesn't hit anything keep moving
Your answer
Follow this Question
Related Questions
How to check if two objects collide without a collider 1 Answer
Instantiate 1 object after 2 objects collide. ( C# ) 1 Answer
How can I detect a collision between two clones and delete them both? 1 Answer
How to perform one pass collision detection on many objects? 2 Answers
Script not recognizing collision 3 Answers