Question by
bodec · Apr 02, 2016 at 03:37 PM ·
scripting problemconstantforce
Is it possible to change constantforce.y ?
Below is the code very raw and simple and I was wondering if there is a way to set the relative force on separate axis what I have does not seem to change anything in the inspector. Attempting to access the component Constant Force tried constantforce.relativeforce.y and didn't work
public ConstantForce cf;
void FixedUpdate()
{
float vertMovement = Input.GetAxis("Vertical") * 10f;
if (vertMovement != 0) {
ThrustUp(vertMovement);
}
}
void ThrustUp(float up) {
Debug.Log(up);
cf.relativeForce = new Vector3(0,up,0);
}
Comment
Ok so after some more testing I have found I am adding force but it doesn't show in the inspector new code looks like any ideas as to why it doesn't show?
float thrustForce = Input.GetAxis("$$anonymous$$ouse ScrollWheel") * trust$$anonymous$$ultiplier;
if (thrustForce != 0) {
ThrustUp(thrustForce);
}
void ThrustUp(float up) {
if (up != 0) {
cf.relativeForce += new Vector3(0, 0, up);
Debug.Log(up);
}
}