About Store Forum Documentation Contact



Post Reply 
Wobbly screen
Author Message
Altair Offline
Member

Post: #1
Wobbly screen
Hi,
I have a problem. I try to make the possibility of riding on horse in my game.
Everything is good but the screen shakes.
http://www.youtube.com/watch?v=f7GEhadksXo

I have such a code:
Code:
struct Horse : Game::Chr
{
    (...)
};

(...)

Game::ObjMemx<Horse>  horses;

(...)

struct Player : Game::Chr
{
        (...)
    bool onhorse;        //true when riding on horse
    Horse *horse;        //pointer to horses member
    (...)
};

(...)

Game::ObjMemx<Player>  player;  

(...)

In Player::Update() i have:
Code:
Player::Update()
{
    (...)

    if(!action)
    {
        if(!onhorse)
        {
            input.anglei.x = Kb.b(KB_Q) - Kb.b(KB_E);
            input.anglei.y = Kb.b(KB_T) - Kb.b(KB_G);
            input.diri.x = Kb.b(KB_D) - Kb.b(KB_A);
            input.diri.z = Kb.b(KB_W) - Kb.b(KB_S);
            input.diri.y = Kb.b(KB_SPACE) - Kb.b(KB_LSHIFT);

            input.dodge = Kb.bd(KB_D) - Kb.bd(KB_A);
            input.crouch = Kb.b(KB_LSHIFT);
            input.walk = Kb.b(KB_LCTRL);
            input.jump = (Kb.bp(KB_SPACE) ? 3.5 : 0);

            Flt max = DegToRad(900) * Tm.d(),
                dx = Ms.dir_ds.x * 1.7,
                dy = Ms.dir_ds.y * 1.7 * Ms.inv();
            angle.x -= Mid(dx, -max, max);
            angle.y += Mid(dy, -max, max);

            if(health > 0)
                ready ^= Kb.bp(KB_R);
        }
        else
        {
            horse->input.anglei.x = Kb.b(KB_Q) - Kb.b(KB_E);
            horse->input.anglei.y = Kb.b(KB_T) - Kb.b(KB_G);
            horse->input.diri.x = Kb.b(KB_D) - Kb.b(KB_A);
            horse->input.diri.z = Kb.b(KB_W) - Kb.b(KB_S);

            horse->input.dodge = Kb.bd(KB_D) - Kb.bd(KB_A);

            Flt max = DegToRad(900) * Tm.d(),
                dx = Ms.dir_ds.x * 1.7,
                dy = Ms.dir_ds.y * 1.7 * Ms.inv();
            horse->angle.x -= Mid(dx, -max, max);
            horse->angle.y += Mid(dy, -max, max);

            angle.x = horse->angle.x;
            angle.y = horse->angle.y;
        }
    }

    if(onhorse)
    {
        pos(horse->matrix().pos+Vec(0,2,0));        
    }
}

I tried also in Player::Update():
Code:
    if(onhorse)
    {
        if(ctrl.actor.collision())
            ctrl.actor.collision(false);

        if(ctrl.actor.gravity())
            ctrl.actor.gravity(false);
    }
But it's not changed.
01-21-2010 01:10 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Wobbly screen
you muse also use
player::reliesOn(){return horse;}

and you'll need to change Horse *horse into reference, because later you might get errors if you dont do that
01-21-2010 03:43 PM
Find all posts by this user Quote this message in a reply
Altair Offline
Member

Post: #3
RE: Wobbly screen
I change Horse *horse; into Reference<Horse> horse; and use
Code:
Game::Obj *Player::reliesOn()
{
    if(onhorse) return &horse();
    else return __super::reliesOn();
}
but nothing changed :(
01-21-2010 06:51 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Wobbly screen
also
1. please set physics in timestep variable mode (Physics.timestep)
2. set player position "pos(horse->matrix().pos+Vec(0,2,0));" before calling __super::update
01-21-2010 06:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Wobbly screen
and also try setting camera before or after game::world.update
01-21-2010 06:57 PM
Find all posts by this user Quote this message in a reply
Altair Offline
Member

Post: #6
RE: Wobbly screen
I add Physics.timestep(PHYS_TIMESTEP_VARIABLE); in Init
and set pos(horse->matrix().pos+Vec(0,2,0)); after __super::update() and it's work.

Thanks!
01-21-2010 07:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply