UnSetPosition?

Topics regarding Scripting with Reality Factory
Post Reply
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

UnSetPosition?

Post 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? :?:
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: UnSetPosition?

Post by Danimita92 »

bump?
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: UnSetPosition?

Post by Juutis »

Could you post the script?
Pain is only psychological.
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: UnSetPosition?

Post 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...
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: UnSetPosition?

Post by Danimita92 »

Fixed. Part of the pawns collision box was inside a brush :lol:
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: UnSetPosition?

Post 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.
Pain is only psychological.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: UnSetPosition?

Post 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.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: UnSetPosition?

Post 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. :)
Pain is only psychological.
Post Reply