#So till now the user is able to place

1 messages · Page 1 of 1 (latest)

burnt condor
#

what do you mean by stacking

digital shard
#

placing multiple prefabs on top of one another

burnt condor
#

so I take it that you can place multiple things in a single tile

digital shard
burnt condor
#

so what cannot be erased?

digital shard
#

these hearts

#

cNnot be erase and can be stacked

burnt condor
#

so my understanding is that the tiles determine where the player can place prefabs on

digital shard
#

that eraser tool should be able to erase

burnt condor
#

Whats the code for erasing things

digital shard
#

those gray can be but hearts canot

digital shard
#

just passing no tiles erases them

burnt condor
#

Have you checked that if your raycast can actually detect the hearts?

digital shard
#

what is a raycast

burnt condor
#

my bad

#

yours is a 2D game

#

you should be using the 2D part of Physics

digital shard
burnt condor
#

read up a bit on the raycasting

digital shard
#

2D has raycast too

burnt condor
#

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

digital shard
#

i havent used it till now, is it bad?

burnt condor
#

No its not. Its probably the most go to way to interact with the world

burnt condor
#

here's where you'll have to do a little bit of digging around youtube/stackoverflow or just the internet itself

digital shard
#

need to create a raycast too right?

burnt condor
#

yep. plenty of tutorials on youtube on raycasting

digital shard
#

create ray, check if it collides, and destory if it collides with hearts

#

oke i will check it and contact u again

digital shard
#

thank you very much

digital shard
burnt condor
#

for that you'll need a reference to the camera

digital shard
#

oke

digital shard
#

the raycast only worked when i instantiate it

#

after the prefab is spawned it didnt detect hit

burnt condor
#

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

digital shard
#

yep

#

i need to use raycatHit2d ?

burnt condor
#

yes i think thats the correct one

#

my apologies

digital shard
#

cannot convert to 2d

#

if i use this it does work but like earlier, it doesnt show hit after it is already created

burnt condor
#

here

#

raycasting in 2D is formatted slightly different than in 3D

digital shard
#

how do i destroy the gameobject i touch

#

mean

#

what does this men

#

i require your assistance again

#

i did the destroy part but how do i make them non stackable

burnt condor
#

hmm it appears you are trying to destroy the prefab itself

#

try Destroy(hit.collider.gameobject) instead