Page 1 of 1

UnSetPosition?

Posted: Fri Jun 19, 2009 7:53 pm
by Danimita92
Hi everybody! :D
In one pawn I made another one have a certain position with
SetPosition("jugador", self.current_X, self.current_Y + 30, self.current_Z);

And then go to another order.

In the second pawn, I give ForceUp and ForceDown commands whenever a certain key is pressed.

However, the second pawn seems to be stuck in the position from the SetPosition, even though this command isn't being run (console says the first pawn is in the other order) :evil: .
So... how can I UnSet it's position? :?:

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 10:02 am
by Danimita92
bump?

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 10:29 am
by Juutis
Could you post the script?

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 5:01 pm
by Danimita92
the important bit is:

Code: Select all

Detect[()
    {
        debug(self.current_yaw);
        if(GetEventState("Climb"))
        {
            if(jugador.current_X < self.current_X + 20 and jugador.current_X > self.current_X - 20)
        {
        if(jugador.current_Z < self.current_Z + 20 and jugador.current_Z > self.current_Z - 20)
        {
        if(jugador.current_X < self.current_Y + 240 and jugador.current_X > self.current_X - 20)
        {
            if(jugador.IsFalling = true)
            {
                self.think = "Active";
            }
        }
        }
        }
        }
        else
        {
        if(jugador.current_X < self.current_X + 20 and jugador.current_X > self.current_X - 20)
        {
        if(jugador.current_Z < self.current_Z + 20 and jugador.current_Z > self.current_Z - 20)
        {
        if(jugador.current_X < self.current_Y + 240 and jugador.current_X > self.current_X - 20)
        {
            if(jugador.IsFalling = true)
            {
                SetEventState("Climb", true);
                SetAttribute("Ledge", 1, "jugador");
                switch (ROT)
                {
                    case 0
                    {
                        
                    }
                    case 1
                    {
                        jugador.ideal_yaw = self.current_yaw;
                        OFFSETX = -5;
                        OFFSETZ = 0;
                    }
                    case 2
                    {
                        
                    }
                    case 3
                    {
                        
                    }
                }
                SetPosition("jugador", self.current_X, self.current_Y + 30, self.current_Z);             
                self.think = "Active";
            }
        }
        }
        }
        }
    }]
    
    Active[()
    {
        //Console(false);
    }]
The actual script that is affected by the SetPosition goes to a new order in which

Code: Select all

{
    SetCollision(); 
    if(AnimationSpeed != 2)
    {
        AnimationSpeed(2);
    }
    ChangeYaw();
    Gravity(false);
    if(GetAttribute("Ledge") = 1)
    {
        ANIM = StringCopy("HangVertical");
        if(IsKeyDown(K_BAK))
        {
            ANIM = StringCopy("HangVerticalDown");
            ForceDown(10);
        }
        if(IsKeyDown(K_FOR))
        {
            ANIM = StringCopy("HangVerticalUp");
            ForceUp(10);
        }
    }
    
    //Animaciones
    if(Integer(LASTANC) != Integer(ANC))
    {
        AnimateBlend(ANIM,0.1);
    }
    LASTANC=Integer(ANC);
    if(self.animate_at_end)
    {
        AnimateHold(ANIM);
    }
    SetEventState("Aimable",false);
}]
But ForceUp and ForceDown don't do anything...

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 7:16 pm
by Danimita92
Fixed. Part of the pawns collision box was inside a brush :lol:

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 7:28 pm
by Juutis
Ah good. I tested the orders and as they worked fine, I braced myself for writing a long post about what the problem could be. Good thing I didn't have to do that. :)

Just one thing: I think you should use the flymove() command instead of applying forces. That way you're guaranteed to get the specific movement speed (X units per second). With forces the speed will vary depending on your frame rate.

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 8:27 pm
by QuestOfDreams
Juutis wrote:Just one thing: I think you should use the flymove() command instead of applying forces. That way you're guaranteed to get the specific movement speed (X units per second). With forces the speed will vary depending on your frame rate.
This is not true. Forces are independent of the frame rate. But there's a difference between a force and a velocity.

Re: UnSetPosition?

Posted: Mon Jun 22, 2009 9:02 pm
by Juutis
QuestOfDreams wrote:This is not true. Forces are independent of the frame rate. But there's a difference between a force and a velocity.
Yes, but if the script is designed to apply the force, say, 20 times a second and the game runs with 10FPS, would it still be the same? Or if the force is applied every frame (ThinkTime = 0), would it matter if the game ran with 1FPS or with 50FPS?

***EDIT***
I was under the impression that the force commands added to the already existing force of the entity but after taking a look at the source code this doesn't seem to be the case. Sorry for the misleading information. :)