- Home /
Tiles painted at runtime + 2D RycastAll = problem!
Hello,
Im working on 2D project where environment is built on tilemap with tilemap collider (+ composite collider). I'm moving objects, paiting tiles, testing and saving layout to file at runtime, and then I'm able to load any level whenever I want BUT in this game player is able to move some rectangular objects, let's call them movables.
Short version:
Raycast on movable (which is moving witch constant speed) stops detecting tilemaps after painting some tiles away from movable..
Long version:
Movables can be moved left and right or be pushed off the edge if player wants to do that. When *movable*is touching ceiling (built from tilemap) some things happen so I'm checking that with two 2D Raycasts.All on top left and top right side of movable. Im detecting if raycast hits tilemap or not.
Pictures:
gray block - movable
black blocks - tile map
two yellow and barely visible lines on top of movable - thats raycasts for detection
Debug.LogError() goes whenever raycast stops hitting tilemap. In first picture you can see how it works after loading saved level (it works as it should). Second and third picture shows what happens after painting tilemap at runtime and moving *movable*afterwards. If I paint tilemap, save layout and load it after hitting play button in editor everything works properly. Strange indeed...
Using Unity 2020.1.14f1
Thanks for any thoughts on that situation!