Jump to content

Ability To Change PlayerCharacter Capsule Scale

Recommended Posts

I need it for my open world game please. The problem is my character model is smaller than the player character capsule. I can't make the player model size any bigger.


If you know any way how to change player character shape, let me know.


Problem: Player model floats on ramps, and dips on flat surfaces.


Share this post

Link to post

Okay man. FYI, if you scale down character like that, you may still run into floating point problems, since it is all relative to player size and camera range.

Share this post

Link to post

What was your solution?


My problem is my characters are suppose to be like 4 feet yet the player controller has a height fixed at 6 feet.

Share this post

Link to post

Yes interesting indeed. Well I'm working on this since fast 2 years. (not only that happy.png )


The solution was very easy, easier as I first could think. I tried many things but everytime something goes wrong, this now looks satisfying.

I want to publish more like for example a playable demo map so everyone who wants can test it. But I will test more first. Thx for the interest, let's go:


Well assuming you want to move the player on the east. I just make a vertical pick() test on the east side of the sphere (with two pivots as childs) and pickinfo.position gives me the next position where the player should go, I mean I get the next position on the terrain no matter if it goes up or down.

Then I just use PhysicsSetPosition() to let the player goes there. That's it, simple or not ?


You can limit the ability of the player to climb by calculating the distance between the actual player position() and the next step he will (pickinfo.position), that's made using DistanceToPoint().


So using this you can make with good detection your player jump over a wall like in assassin creed for example (with the right coordinated animation of course!) or recognizes and reacts to any animation specific entity/items in the world...


I did not use addforce() or anything like this.

When the player doesn't move (test if all KeyDown()==false) then Player:SetMass(0). Player stops as it should.


Sorry my english is a school one, don't hesitate to ask if not understandable ok, here I made this quickly:






A very short video link to this more (I hope it's not boring!)

You can see how it goes quickly, smoothy and here how the player can climb higher as usual, (only have changing one value) but can not climb all the walls (collision persists if wall too high)

Share this post

Link to post

We need this for a lot of other cases, like not humanoid characters, or crouching.


My player can crouch. I just have to do a raycast check to see if they can stand up again which isn't perfect....

Share this post

Link to post

Very interesting Marc. So to move faster I assume you increase the distance of the pivots from the player so the next position will be farther away?

Share this post

Link to post

What happens in situations like this?


Pick on the left would tell you that you can't go there even though you can pass under the object. Pick on the right would tell you that you can go even though there is a wall.


If you don't use pick to check if you can pass or not, then you will get laggy behavior when running against a wall with SetVelocity or PhysicsSetPosition.


You can avoid that by using AddForce, but then you can't instantly change speed in another direction. I had to add extra forces just to compensate this delay. From my monthly script challenge script:

local velocity=playerMovement*3 --speed that we want to get (if walking)

local currentSpeed = self.entity:GetVelocity(false)

currentSpeed.y=0 --we don't want to affect the gravity so we don't include it in calculations

local extraSpeed = velocity-currentSpeed --speed that we lack

velocity=velocity+extraSpeed*200 --adding lacking speed



I'm prety sure all this can lead to pretty bad behavior when touching other rigid bodies.

Share this post

Link to post

@ reepblue: how did you manage with the shape ?


@ Rick, That's exactly as you said. thx I forget this.


@ Genebris:


If I had obtained bad behavior I would not have published here. I was the first surprised about this because I search for this since 2 years now, I tried complicated things with AddForce and AddTorque and I decided to forget all of this because of no satisfying result and I got back to the classic Character controller...Then I wanted to try this.


Well, the two situations are solved in the videos I posted:


1) The one on the right of your picture is pretty simple because the PhysicsSetPosition() seems to take care of the collision:


please pay attention at 0,20 and 0,48


at 0.08


As Rick mentioned the distance between the sphere-character and the pivots is important for the speed but no needs to be very far so it lets the classic collision occurs as if I had used the AddForce() function.


2) The situation on the left of your picture could occur but I see this as a chance not as a bug wink.png

Because you can decide where to put the first pivot position height depending on if you want your character to jump on the plateform or if you prefer to let him crouch under, for example (did you play assassin creed?):


if KeyDown(x) then CheckOverThePlayer() -> function would place the first pivot over his head, player animated in a run-up idle

elseif KeyDown(y) then CheckInFrontThePlayer() -> function would place the first pivot somewhere under his head and scale the shape to * 0.5, otherwise it would collide, player in a crouch animation for example.



Please check here

at 1.35


Share this post

Link to post

This is even visible in your video

Character and camera is shaking because it tries to run into a wall. And this is getting worse on higher speed.


You can avoid that with pick check, but you will have problems that I described.

You can avoid that by using AddForce, but you will have other problems that I described.


Also, rigid body bounces like crazy when falls on the ground, and we have no control over that.

Share this post

Link to post

I would think you can avoid the shaking of the camera by not having it be parented and instead having full control over it following the player and be smoothed.

Share this post

Link to post

No I'm afraid I understand what Genebris means. He means the shock vibrations between the collision Shape of an object and the physics force that moves the player. I didn't think about that yet. You can smooth as you want it should not occur.


Next step would be to stop the force by such appropriate collision or maybe using the colllision() function I'm thinking about this...




I fixed this problem.

As those vibrations are unfortunately not to get cleared, but as we need a collision shape, the final solution seems to simulate a fake collision item moving with mass in front of the player and catching the collision informations + vibrations for us.


We let him invisible shaking just as it wants and collect the usable informations for the visible player. Here the results of this:

Visible Shape=

Invisible Shape=



Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...