Jump to content

#1
jen

jen
  • Members
  • 229 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.
Posted Image

#2
jen

jen
  • Members
  • 229 posts
Found a solution. No worries.

#3
Josh Klint

Josh Klint
  • Staff
  • 11,130 posts
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.

#4
martyj

martyj
  • Members
  • 327 posts
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.

#5
Genebris

Genebris
  • Members
  • 269 posts
We need this for a lot of other cases, like not humanoid characters, or crouching.

#6
Marcousik

Marcousik
  • Members
  • 100 posts
please check this I made today:

https://youtu.be/ndCePTQRoJ0

The sphere could be any size...

#7
gamecreator

gamecreator
  • Members
  • 1,873 posts
Very interesting Marcousik.  How was that done?  For example, how does the sphere not roll down ramps?

#8
Marcousik

Marcousik
  • Members
  • 100 posts
Yes interesting indeed. Well I'm working on this since fast 2 years. (not only that Posted Image )

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:

Attached File  Dessin.jpg   62.48K   0 downloads

Edit

A very short video link to this more (I hope it's not boring!) https://youtu.be/cZ1X138QmRM
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)

#9
reepblue

reepblue
  • Members
  • 478 posts

View PostGenebris, on 17 February 2017 - 04:02 PM, said:

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....

#10
Rick

Rick
  • Members
  • 7,039 posts
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?

#11
Genebris

Genebris
  • Members
  • 269 posts
What happens in situations like this?
Attached File  e.png   7.42K   0 downloads
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
self.entity:AddForce(velocity,false)


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

#12
Marcousik

Marcousik
  • Members
  • 100 posts
@ 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:
   - https://youtu.be/ndCePTQRoJ0  please pay attention at 0,20 and 0,48
   - https://youtu.be/cZ1X138QmRM 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 Posted Image
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.
end

Please check here https://youtu.be/ndCePTQRoJ0 at 1.35
thx

#13
Genebris

Genebris
  • Members
  • 269 posts
This is even visible in your video
https://youtu.be/cZ1X138QmRM?t=10s
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.

#14
Rick

Rick
  • Members
  • 7,039 posts
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.

#15
Marcousik

Marcousik
  • Members
  • 100 posts
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...


Edit
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= https://youtu.be/ixM-PdhR0M0
Invisible Shape= https://youtu.be/z7ZpyLBqbHc

thx

#16
Marcousik

Marcousik
  • Members
  • 100 posts
(sorry double post)