- Home /
creating a linked object mesh
hey everyone, the game I am currently developing starts off by generating a bunch of prefabs, the prefabs then delete their original box colliers and link together through meshes, these meshes then create collisions and wala awesome. however the problem is the game won't do this.
code below:
private var hasrend:boolean;
private var playerobject:GameObject;
playerobject = GameObject.Find("FPC");
private var isdone:boolean;
function Start ()
{
var hit : RaycastHit[];
hit = Physics.SphereCastAll (gameObject.transform.position, 1.0F,transform.forward,360, 8);
if(hit != null)
{
var mesh : Mesh = new Mesh ();
GetComponent(MeshFilter).mesh = mesh;
mesh.vertices = [hit[1].transform.position,hit[2].transform.position,this.transform.position];
mesh.triangles = [0, 1, 2];
this.AddComponent(MeshCollider);
hasrend = true;
isdone = true;
}
else
{
isdone = false;
hasrend = false;
}
}
function Update ()
{
if (!isdone && !hasrend)
{
var hit : RaycastHit[];
hit = Physics.SphereCastAll (gameObject.transform.position, 1.0F,transform.forward,360, 8);
if(hit != null)
{
var mesh : Mesh = new Mesh ();
GetComponent(MeshFilter).mesh = mesh;
mesh.vertices = [hit[1].transform.position,hit[2].transform.position,this.transform.position];
mesh.triangles = [0, 1, 2];
this.AddComponent(MeshCollider);
hasrend = true;
isdone = true;
}
else
{
isdone = false;
hasrend = false;
}
}
}
function Start ()
{
var hit : RaycastHit[];
hit = Physics.SphereCastAll (gameObject.transform.position, 1.0F,transform.forward,360, 8);
if(hit != null)
{
var mesh : Mesh = new Mesh ();
GetComponent(MeshFilter).mesh = mesh;
mesh.vertices = [hit[1].transform.position,hit[2].transform.position,this.transform.position];
mesh.triangles = [0, 1, 2];
this.AddComponent(MeshCollider);
hasrend = true;
isdone = true;
}
else
{
isdone = false;
hasrend = false;
}
}
I'm new around here so don't hound me to much
You're new around here, so the first thing you should do is format your code so we can read it!
Having formatted it, could you please describe the exact problem you are having? Just looking at code aimlessly doesn't help much.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062158im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Overlapping meshes create weird rendering problem 1 Answer
How to glue multiple objects together 0 Answers
Confining / Constraining an object transform trajectory to a mesh 1 Answer
Platform should bend when object falls 0 Answers
May I substitue the default particles with my particular mesh? 2 Answers