This content has been marked as final. Show 2 replies
Seem to be able to associate the camera with the character but the camera is not sticking with the character when it moves. Heres the code I have now:
characterCam = MyWorld.camera
characterCam.transform.position = character.worldposition + vector (0,0,5)
characterCam.transform.rotation = vector(90,0,180)
i made a camera following a character this way:
1. i made 3 boxes invisible(box1.shader.blend = 0), box1 over the character ,box2 behind the character and box3 is intepolateing to box1
characterrotate = character.transform.rotation.z -- characterrotate is a var
box2.transform.position.y = character.transform.position.y -- character is the moveing character
box2.transform.position.x = character.transform.position.x -250 --moves box2 250 units behind character
box1.transform.position.z = character.transform.position.z + 30 -- moves box1 30 units above character
box1.transform.position.y = character.transform.position.y
box1.transform.position.x = character.transform.position.x
camera1.transform.interpolateto(box2.transform,30) --camera interpolates to box 2
camera1.pointat(box3, vector(0,0,1)) -- camera points at box 3 witch is interpolateing to box 1
2. the camera is using "interpolateto" becouse i dont want the camera to be fixed on the box, if the camera is fixed on the box it can result in a "noisy" movement of the camera( the camera may go up and down when the character follows a rough terrain)
the camera point's at box3 to follow the charater in a more natural manner.
Now if you move the characterter camera will follow and always point on on him.
hope i made no mistakes in the script and sorry for my bad english.