Why isn't raycast working?

I’m trying to create a placeable block. It follows the mouse on the grid, with it disabled, and then when you click, it is enabled. However, proximity doesn’t have the “any type”, and when I tried raycasting it didn’t work. Does anyone have a way to make a placeable block? A way to know if it’s over an object?

1 Like

Why isn’t ray cast working?

I don’t know…

I’m not sure about raycasting transferring onto a spawnable object, as I haven’t tried it before. But if it’s supposed to detect multiple different objects. Create a parent object and the objects you do want to be detected, set it’s parent object to the one you selected.

Then have the raycast detect the parent object so all objects with the parent enabled should be detected. Not sure if this will work, but it should help instead of just trying to detect all objects at once.

1 Like

If you’re trying to spawn on a grid, ray cast isn’t the way to go.

Do this instead in an expression

Math.round(X/32)*32, this is for the X
Math.round(Y/32)*32, this is for the Y

You can change the 32 to be a smaller or larger number depending on the grid size you want


yup, I did that. The spawning on the grid part is fine, but I don’t know how to see if there is already an object where it’s being placed.

Raycasts don’t really work if it’s inside the object, you’ll need to hit the edge. So for this just have the ray caster displaced downwards so that it can detect the edge, or you can just use collision (probably the most effective method).
Hit any → activate means there is something there

1 Like

Or use a lot of proximities, but that takes some work.

1 Like

Proximity is more complicated and more lag intensive, just a simple collision check should do the job.
Also welcome to Flowlab! Nice to see new users

1 Like

If I use collisions, that will output once. How do I know if it is still there???

Oh right you don’t want to be able to place it on animals, I was thinking of just walls.
Just use a single proximity set to the parent of the animals, I believe this is what Maniac said. Then use the Collision to detect for walls. These checks should be made by the spawner, not the actual wall itself

1 Like

right, so if it gets a wall collision, it turns off the ability to put the block down until if moves.

I believe both the collisions and the proximity should be in the wall…

Depends on what system you’re using. Based on how I would design it I would not, but you could design it differently.

1 Like