#How can I get a list of vertices of a GameObject?

1 messages · Page 1 of 1 (latest)

tired basalt
#

I'm attempting to implement some form of GJK algorithm, and I need the vertices of the box representing the player and the vertices of some other object we want to see if we collide with to then do math on. How can I obtain this list of vertices? (I am just testing with two GameObject cubes since this will eventually be checking against map geometry)

solemn compass
#

Primitive colliders do not make their vertices accessible; in the case of a cube, figuring those out should be trivial anyway.
And if you are using a MeshCollider/MeshFilter, you can simply access their sharedMesh property and then that mesh's vertices.

tired basalt
#

so if my game object has a collider, i can access the collider's vertices but not directly the actual object essentially?

#

even tho finding vertices of a cube is trivial i want it to work with any arbitrary convex piece of geometry

solemn compass
#

GameObjects are just a name, a tag, a layer, and enabled state and a few flags.
Transforms are just a point, a scale and a rotation. (plus some hierarchy information).
Neither of those has any geometry whatsoever. So no, you cannot get vertices from the "actual object", because that does not have vertices.

#

You can, however, write an extension method that returns an array of vertices, based on which components it finds on a given object. That's the closest you'll get.

tired basalt
#

i see

#

thank you

solemn compass
#

you're welcome blobOk