#So till now the user is able to place
1 messages · Page 1 of 1 (latest)
placing multiple prefabs on top of one another
so I take it that you can place multiple things in a single tile
yes sir
so what cannot be erased?
so my understanding is that the tiles determine where the player can place prefabs on
Whats the code for erasing things
those gray can be but hearts canot
i jus replace tile with empty
just passing no tiles erases them
Have you checked that if your raycast can actually detect the hearts?
what is a raycast
yes
read up a bit on the raycasting
2D has raycast too
yes
the concept is just casting a ray into the world and getting back anything that ray intercepts with
in your case, we want it to intercept with the hearts, retrieve them in code and then destroy them
i havent used it till now, is it bad?
No its not. Its probably the most go to way to interact with the world
so.. how do i do that
gotcha
here's where you'll have to do a little bit of digging around youtube/stackoverflow or just the internet itself
need to create a raycast too right?
yep. plenty of tutorials on youtube on raycasting
create ray, check if it collides, and destory if it collides with hearts
oke i will check it and contact u again
yes you got it
thank you very much
so a raycast needs an initial point and it can be mouse click?
yes it can
for that you'll need a reference to the camera
oke
the raycast only worked when i instantiate it
after the prefab is spawned it didnt detect hit
Try doing a Debug.Log on the obejct you've hit to make sure its really the heart its intercepting with
Note that for the raycast to hit something, that something needs a collider on it
cannot convert to 2d
if i use this it does work but like earlier, it doesnt show hit after it is already created