[SOLVED] Camera bobbing up and down

Could I do something like

this.app.systems.rigidbody.applyforce(0,25,0);

Yes.

if (this.app.keyboard.isPressed(pc.KEY_W)) {
    if (this.entity.getPosition().y < 0.5) {
        this.entity.rigidbody.applyForce(0, 25, 0);
    }
    else {
        this.entity.rigidbody.applyForce(0, -25, 0);
    }
}

it says this.app.keyboard.ispressed is not a function

Yes, can you pay a little more attention to correct capitalization yourself please? I take over your code and don’t check every letter every time myself. It’s isPressed and not ispressed.

the script is in the player

It wont work

the player wont bob up and down

Maybe the player position is already higher then 0.5 by default.

it is so do I update it in the script to be higher?

Yes, give it a try.

its workin just gotta find the correct values and I should be good! Thanks!

2 Likes

it no work

Reading back I indeed think it need some modification to make it work. What is your result so far?

I tried it, but it didn’t work as expected. Below a project that another user made. I hope this is the effect you are looking for. I think it’s a really cool effect!

https://playcanvas.com/project/986420/overview/unity-head-bob

I took a look at it, I dont have a camer holder nor do I want one, so how I get it to work?

Because?

Probably not?

I do not know what camera holder does

It’s probably just an empty entity that is needed to create the bobbing effect you try to achieve.

I added it but it still know work, it also mess up when I look down
https://playcanvas.com/editor/scene/1590781

If you want to achieve something, you have to put in some effort. Nothing works out of the box.

4 Likes