x


Locking the camera's Y position while jumping.

I have a character which is the parent of a camera, when the character jumps, the camera jumps as well (no surprise). I would like to lock in the camera's Y position when the character jumps so it stays steady and no longer jolts upwards. I've wrote a script to do this but it doesn't work very well as the camera jitters when the player jumps while using it, here it is: EDIT: I should note that this is a third person game.

var originalY;

function Start(){
    originalY = transform.position.y;
}

function Update () {
    if(altThirdPersonController.isJumping==true){
        transform.position.y = originalY;
    }
}
more ▼

asked Apr 21 '10 at 05:26 PM

Nathaniel gravatar image

Nathaniel
5 2 2 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You could always make "jumping" an animation and not actually move the object up and down.

Alternatively, you could have a parent object that the camera and model are both bound to (so they're siblings), and have the movement control this invisible object, and jumping only affect the model.

more ▼

answered Apr 21 '10 at 07:26 PM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

Creating an invisible object seems to have done the trick, thank you!

Apr 21 '10 at 07:40 PM Nathaniel
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3009
x90

asked: Apr 21 '10 at 05:26 PM

Seen: 1133 times

Last Updated: Apr 21 '10 at 05:26 PM