About Store Forum Documentation Contact



Post Reply 
Changing capsule controller height, how?
Author Message
SamNainocard Offline
Bronze Supporter

Post: #1
Changing capsule controller height, how?
I having a problem with capsule controller's height.
The controller only allow me to change the controller radius, but not height.

Right now, I'm manually animate an animation and using custom crouch without using input.crouch because it is interfered with some system.

Because I want to change the height slowly as character is crouching or standing, not instantly.

   

Thanks in advance.
03-09-2012 04:37 PM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #2
RE: Changing capsule controller height, how?
It's impossible. I tested.
(This post was last modified: 03-11-2012 04:24 AM by Dampire.)
03-11-2012 04:23 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #3
RE: Changing capsule controller height, how?
So much for the impossible wink

Inside controller class(Controller.h)
Code:
void height(Flt height){_height = height;};

Code:
if(Kb.bp(KB_T)){
    Player.ctrl.height(RandomF(0.4f,1.7f));
    Player.ctrl.createCapsule(Player.ctrl.radius(),Player.ctrl.height(),Player.​pos(),&Player.ctrl.center());
}
(This post was last modified: 03-11-2012 09:26 PM by Zervox.)
03-11-2012 09:03 PM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Bronze Supporter

Post: #4
RE: Changing capsule controller height, how?
Never known I can change .h with free license, but isn't it work just like
PHP Code:
Player.ctrl.createCapsule(Player.ctrl.radius(),RandomF(0.4f,1.7f),Player.​pos(),&Player.ctrl.center()) 

Because changing _height, without recreate seems to make character float around.

Edit: So, I guess it's the only way, time to figure out how to change height without making character warp around or fall through world. pfft

Edit2: I can't seem to get it done, when changing height mid-air will pull character onto the ground almost instantly. With actor.freezePosY(true) still make crouching feel weird.
(This post was last modified: 03-12-2012 09:43 AM by SamNainocard.)
03-12-2012 06:43 AM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #5
RE: Changing capsule controller height, how?
2Zervox
Omg... Why are you changed function, if you use it just as storage for one variable? Recreating controller isn't solution. PhysX controller can't dynamically change height (without recreating of course). So... It's impossible, isn't? Much easier to write own controller with normal states of standing, crouching, prone.
(This post was last modified: 03-19-2012 04:22 AM by Dampire.)
03-19-2012 04:21 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Bronze Supporter

Post: #6
RE: Changing capsule controller height, how?
I was thinking about case of character is standing on another character, and sometime when another character try to jump above character.

Now, I don't need to slowly changing the capsule height, just change the height once start crouching or standing (not after)). Because it's seems unnecessary.

but current problem I have is recreating actor seems to pull a character to the ground (or even fall though world).
(This post was last modified: 03-20-2012 06:22 AM by SamNainocard.)
03-20-2012 06:18 AM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #7
RE: Changing capsule controller height, how?
Pseudocode:
temp = ctrl->getPos();
ctrl->recreate();
ctrl->setPos(temp);
03-21-2012 04:07 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Bronze Supporter

Post: #8
RE: Changing capsule controller height, how?
(03-21-2012 04:07 AM)Dampire Wrote:  Pseudocode:
temp = ctrl->getPos();
ctrl->recreate();
ctrl->setPos(temp);

I believe I have tried that, anyway, I tried it again today and end up with...

1#
PHP Code:
Vec tempp=ctrl.actor.pos(),
      
vel=ctrl.actor.vel(),
      
center=ctrl.center()+Vec(00.250); // Adjust capsult position to make it at character's feet.

Flt radius=ctrl.radius(),
     
height=ctrl.height()-0.5;    //ctrl.height()+0.5 for standing

ctrl.createCapsule(radiusheighttempp, &center).actor.pos(tempp).vel(vel); 
Result are very good on flat terrain, but on hill, character will jumpy uphill when crouching. And losing height while crouching on air. ( O display old position before recreate, x after create. I have manage to make it fit together but not between crouching and standing. )

       

I figure it's to do with freezePos() but adding freezePos on and off after creation doesn't seem to do anything so I try freezePos on creation time and unfreezing on next update.

PHP Code:
static Bool testCrouch=false,    // For creating actor only once.
             
refrezz=false;       // Unfreezing
static Vec VELZ;                    // Restores old actor's velocity

if (testCrouch==false)
        {
            
refrezz=false;
            
Vec tempp=ctrl.actor.pos(),,
                 
vel=ctrl.actor.vel(),
                 
center=ctrl.center()+Vec(00.250);
            
VELZ=vel;
            
Flt radius=ctrl.radius(),
                 
height=ctrl.height()-0.5;    //ctrl.height()+0.5 for standing
            
            
ctrl.createCapsule(radiusheighttempp, &center).actor.pos(tempp).freezePos(true);
            
            
testCrouch=true;
        }else if (!
refrezz)
        {
            
ctrl.actor.freezePos(false).vel(VELZ);
            
refrezz=true;
        } 

Everything work almost perfect no randomly jumpy on uphill or losing height, but a small stutters but rarely noticeable due to freezing and unfreezing on next update. Also not sure if FPS will making a side effect or not.

Edit: This one recreate actor once start crouching or standing, haven't try slowly changing height yet.
(This post was last modified: 03-21-2012 09:56 AM by SamNainocard.)
03-21-2012 09:49 AM
Find all posts by this user Quote this message in a reply
Post Reply