Does anyone have any idea is it possible to move the camera by x,y,z position axis instead of moving it by Vector3(0,0,0)?
Is it possible that i manually fill in the position axis value inside the bracelet? Thanks
Does anyone have any idea is it possible to move the camera by x,y,z position axis instead of moving it by Vector3(0,0,0)?
Is it possible that i manually fill in the position axis value inside the bracelet? Thanks
Just go transform.position.x = 2;
Thanks for the quick reply Daniel. I tried your method however it doesn’t work out for me. Not sure do u refering to that.
var speed = 5.0;
var terrainData : TerrainData;
var parent : Transform;
var moveSpeed : float = 1;
//terrainData.size.x
var smooth = 2.0;
var tiltAngle = 5.0;
var zRotation = 0.0;
//var tiltZ = Input.GetAxis("Mouse X")*tiltAngle;
var r = camera.pixelRect;
var yRotation = 0.0;
var tiltY = Input.GetAxis("Mouse Y")*tiltAngle;
var clampedZ=0.0;
var rotationSpeed : float = 40;
var rotateAroundYInput: float = Input.GetAxis("Horizontal");
var objectUp: Vector3 = transform.TransformDirection(Vector3.up);
var foo = GameObject.Find("YourObject");
//foo.transform.position.x = 0;
//foo.transform.position.y = 28;
//foo.transform.position.z = 52;
function Update(){
var camera = camera.transform.localPosition;
var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
var z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
transform.Translate(x,0,z);
transform.Translate(Vector3.forward * Time.deltaTime*5);
if( foo.transform.position.x == 0 foo.transform.position.y == 28 foo.transform.position.z == 52){
transform.Translate(Vector3.up * (Time.deltaTime*5), Space.World);
}
if(foo.transform.position.x == 0 foo.transform.position.y == 154 foo.transform.position.z == 174){
transform.Translate(Vector3.forward * Time.deltaTime * 5);
}
}
what i am trying to do is actually when my camera is at Position X= 0, Y=28 n Z =52, my camera will translate upwards. Then when my camera is at position X = 0, Y = 154, Z = 174, my camera will translate forwards. However i can’t achieve any of it. Hope you can help me.
Thanks in advance.[/code]
What part of your script is not working?
From what I remember reading, it’s not a good idea to check for coordinates using == due to precision errors. Try using Mathf.Approximately.
Hi Hanford,
thanks for the reply too. This are the area that is not working.
f( foo.transform.position.x == 0 foo.transform.position.y == 28 foo.transform.position.z == 52){
transform.Translate(Vector3.up * (Time.deltaTime*5), Space.World);
}
if(foo.transform.position.x == 0 foo.transform.position.y == 154 foo.transform.position.z == 174){
transform.Translate(Vector3.forward * Time.deltaTime * 5);
}
Do you mind showing me some example on how to use the function for “Mathf.Approximately”. As i really don’t have any background in javascript. I am really a beginning learner. I am very sorry i hope you understand. Thanks in advance. [/code]
Sorry I never replied to your post; I guess I’m kinda a n00b too and I’m mostly checking this forum for help with my own stuff!
You use mathf.Approximately by putting two numbers into it you want to compare. if it returns true, then they’re approximately close.
example (I’m making this up):
if(mathf.Approximately(1.0000001, 1.0000002))
{print(“these two numbers are approximately the same!”;}
WARNING: You should test this to see how “approximate” it tests. I didn’t actually test the code above.