#Checking two touching Gameobjects for square sides

1 messages · Page 1 of 1 (latest)

lament anvil
#

I have a Prism Gameobject, with a custom mesh filter, and I'm trying to figure out how to detect that the side touching the Cube Gameobject isn't a square, and therefore isn't valid. I only want to allow a square side touching another square side to be valid.

I've been trying get this to work for a few days, but have been unsuccessful.

Any ideas?

modern mulch
lament anvil
#

I thought of doing that as a last resort, but I wanted to see if I could make a generic system for it.

I'm probably going to have a a lot of gameobjects with shapes.

modern mulch
#

That's probably the most generic system there could be. Anything else would be way more specific.

#

I guess you could try messing with the shape vertices, make ray casts from them and compare distances, but I can see a huge amount of issues that would make such an approach unreliable

#

And performance heavy

lament anvil
#

Ok, say I go with predefining a gameobjects sides that can "connect" to other gameobjects sides, how would I do about doing it?

modern mulch
#

Well, define the sides for each shape type. You can do it in any data structure you like: an array of classes or structs on a MonoBehaviour, scriptableobject, json, xml, csv, database.

lament anvil
#

I'm thinking of creating a empty gameobject, making the shape gameobject into a child of it, and then adding in Quad gameobjects to say which side can "Connect".

modern mulch
#

Then at runtime it's just a matter of getting the data of the side of the shape and checking if it's valid for the side of the other shape.

modern mulch
lament anvil
#

Since I don't know vertices, I was thinking of some visual way I could define which sides to allow.

modern mulch
#

Not sure how that's related to the approach we were talking about.

Or are you considering the raycast per vertex approach now?