Clicking the button displays the chair, it breaks with the LMB. The problem is that sometimes creates more than one clone, the other problem is that when creating the clone is always in the original starting position.
Example, if the chair fell on its side, the clone would that appeared in the same position.
help me please
Example : http://testhtml.altervista.org/ChairTest/index.html used W,A,S,D to rotate the main camera
Thanks for the webplayer but i still need to see some kind of codes in order to help you.
And more info please. Maybe explain a little more.
Ok thi is the script for spawn the chair
this for chair broken
Two simple scripts
Use the code tag when posting codes.
Read my sig.
Here you go
Chair .js
// Chair .js
var ChairCrash : Transform;
function OnMouseDrag ()
{
var chairCrashClone = Instantiate(ChairCrash, transform.position, Quaternion.identity);
chairCrashClone.rigidbody.AddForce(transform.forward);
// Destroy it after it broke and for 2 seconds later
Destroy(chairCrashClone, 2);
}
SpawnChair.js
var Chair: GameObject;
var EffectSmoke: Transform;
private var spawnedChair : GameObject;
function OnMouseDown()
{
if (spawnedChair == null)
{
print("Spawned");
spawnedChair = Instantiate(Chair, transform.position, Quaternion.identity) as GameObject;
Instantiate(EffectSmoke, transform.position, Quaternion.identity);
EffectSmoke.rigidbody.AddForce(transform.forward);
}
}
This make sure your chair spawns only once and when you drag shows the broken chair and after some time destroy itself so that you can spawn again.
unfortunately had no change, I changed “OnMouseDrag” in “OnMouseDown” and now generates more than one clone.
But the position does not change the spawn of the clone
You used the scripts that i typed? I tried the ones i type and it works fine. Click on the spawnchair object. Spawns one chair and when i click on chair and drag, will instantiate crash chair add force and then destroy after 2 seconds. Can you post what scripts you are using.
Yes, that’s ok thanks zine92