Sona Rijesh
Sona Rijesh

Reputation: 1035

Mesh Collider in unity3d

I'm new to programming, and am following directions of a book to put together a simple code in javascript.

var Nnet : GameObject; var theNet= Nnet.AddComponent(MeshCollider);

I tried here to add mesh collider to a gameobject.

it shows error.

How can i add a Mesh Collider to this gameobject.

Thanks in advance

Upvotes: 1

Views: 2711

Answers (1)

onevcat
onevcat

Reputation: 4631

You add a BoxCollider Component to the GameObject Nnet. If you want to add a Mesh Collider, try:

var theNet= Nnet.AddComponent(MeshCollider);

You also have to set the mesh collider(here is theNet)'s sharedMesh if you want to use the collider to collide with other colliders. I suggest you add a mesh collider to a GameObject in the edit mode first. Select a gameobject with a mesh and then try Menu->Component->Physics->Mesh Collider. Once you get familiar with it, you can play with code easily.

Upvotes: 2

Related Questions