- Home /
Problem with forcing objects to a 2D plane
I've typed a script that forces an object to a 2D plane; actually revised the Force2D script. Unity errors are Assets/Force2D.js(1,33): UCE0001: ';' expected. Insert a semicolon at the end. Assets/Force2D.js(1,40): UCE0001: ';' expected. Insert a semicolon at the end.
public var forceBetweenXYZ:First Person Contoller="z";
private var Axis:Vector3;//desired depth ;
private var Rotation:Vector3;//desired rotation ;
function Awake(){
Axis=transform.position;//defines the starting z position as the desired Z positoin
Rotation=transform.eulerAngles;//defines the starting rotation as the desired rotation
}
function Update(){//each frame
var spinforce:Vector3=gameObject.ridgidbody.angularVelocity;//is the rotational force on this frame
var place:Vector3=gameObject.transform.position;//is the target position in world space on this frame
if(forceBetweenXYZ=="x"){
if(place.x!=Axis.x){//if the current x position is not the desired x position then...
transform.position.x=Axis.x;//go to the desired x position
}
gameObject.rigidbody.angularVelocity.y=0;//stop rotating around y axis
gameObject.rigidbody.angularVelocity.z=0;//stop rotating around z axis
gameObject.transform.rotation.y=Rotation.y;//resets it to the desired y rotation
gameObject.transform.rotation.z=Rotation.z;//resets it to the desired y rotation
}else if(forceBetweenXYZ=="y"){
if(place.y!=Axis.y){//if the current x position is not the desired x position then...
transform.position.y=Axis.y;//go to the desired x position
}
gameObject.rigidbody.angularVelocity.y=0;//stop rotating around y axis
gameObject.rigidbody.angularVelocity.x=0;//stop rotating around z axis
gameObject.transform.rotation.x=Rotation.x;//resets it to the desired y rotation
gameObject.transform.rotation.z=Rotation.z;//resets it to the desired y rotation
}else{
if(place.z!=Axis.z){//if the current x position is not the desired x position then...
transform.position.z=Axis.z;//go to the desired x position
}
gameObject.rigidbody.angularVelocity.y=0;//stop rotating around y axis
gameObject.rigidbody.angularVelocity.x=0;//stop rotating around z axis
gameObject.transform.rotation.y=Rotation.y;//resets it to the desired y rotation
gameObject.transform.rotation.x=Rotation.x;//resets it to the desired y rotation
if(forceBetweenXYZ!="z")
print("FORCING Z BY DEFAULT,USE X,Y, OR Z LOWERCASE");
}
}
What exactly are you asking? Are you trying to figure out where the missing semicolons go?
from only looking at the first line.
'First Person Contoller'
1) Do you mean controller.
2) You can't have spaces.
3) I doubt First Person Contoller is a string so you cant set it to "z".
you probably want
'public var forceBetweenXYZ:String="z";'
But Im not sure what you are doing.
You probably should have posted that as an answer so the asking user could have accepted it FlyingOstriche :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Audio not playing [Fixed] 1 Answer
Rest postion after animation plays 0 Answers
Object will not instantiate 1 Answer
Assets/MELLE.js(1,15): BCE0044: unexpected char: ';'. 1 Answer