vadozza
September 4, 2016, 3:59pm
1
Hello everybody!
When i trying change mass with following code, after click on object in unity redactor changes mass but there is no effect.
using UnityEngine;
using System.Collections;
public class AppleController : MonoBehaviour {
public Rigidbody2D rb;
void Start () {
rb = GetComponent<Rigidbody2D>();
}
void Update () {
if (Input.GetMouseButton (0)) {
rb.mass = 3f;
}
}
}
But the following code works fine:
using UnityEngine;
using System.Collections;
public class AppleController : MonoBehaviour {
public Rigidbody2D rb;
void Start () {
rb = GetComponent<Rigidbody2D>();
}
void Update () {
rb.mass = 3f;
}
}
What does “redactor changes mass” mean?
Is your mouse-button check passing successfully? Insert a Debug.Log to find out. Also, look at the mass of your object in the inspector. Is it changing? Finally, are there any other scripts involved that might be mucking up the works?
vadozza
September 5, 2016, 4:35pm
3
JoeStrout, thank you for reply!
What does “redactor changes mass” mean?
“Redactor changes mass” means that mass of my object in the inspector is changing.
Is your mouse-button check passing successfully?
Yes, because there are changes in inspector.
Insert a Debug.Log to find out.
Debug.log always prints in console in both cases.
Also, look at the mass of your object in the inspector. Is it changing?
Yes, it is changing.
Finally, are there any other scripts involved that might be mucking up the works?
No, i have only one script in project.
Ok, in that case, it sounds to me like it is working. So why did you say “there is no effect”?
1 Like