- Home /
Unity says that my script isn't doing anything?
I am working on a building game, and I spawn objects & parent them to a master object. Unity is giving me the
Expressions in statements must only be executed for their side-effects.
error. After a little bit of research, I discovered that Unity thinks my script does not do anything. My script obviously does do something, actually it does quite a bit.
here is the script-
#pragma strict
var gamemanager : GameObject;
var spawnedobj : GameObject;
function Start () {
gamemanager = GameObject.FindGameObjectWithTag("gmanager");
}
function OnMouseOver () {
if(Input.GetMouseButtonDown(0)) {
spawnedobj = Instantiate(gamemanager.GetComponent("itemmanager").selectedobject, transform.position, transform.rotation);
spawnedobj.AddComponent(HingeJoint);
spawnedobj.GetComponent(HingeJoint).spring.damper.Mathf.Infinity;
}
if(Input.GetMouseButtonDown(1)) {
Destroy(spawnedobj);
spawnedobj = null;
}
}
any thoughts on what to do?
*javascript only please, duh
*thanks
Answer by Eric5h5 · Jan 31, 2014 at 09:59 PM
spawnedobj.GetComponent(HingeJoint).spring.damper.Mathf.Infinity;
does not do anything. You need to assign values using the = symbol.
Ahh, thank you! I missed that! I'm not the best when it comes to troubleshooting!
Your answer
Follow this Question
Related Questions
For statement errors? 1 Answer
For statement stops function? 1 Answer
Collision of Character collider not working? 1 Answer
For loop not working? 1 Answer