#yes
1 messages · Page 1 of 1 (latest)
sure
it just stops when u jump, and in my controller script when Jump() is called, it just stops the slide by calling StopSlide()
Since This is rigid body based I would expect when u jump u continue going forward some more but instant all velocity just stops
is your jump also force?
Yes
and does it also happen when you just stop sliding and not jumping?
if u stop sliding and dont jump no force should be added but yes it also doesnt conserve momentum
void Jump()
{
Vector3 jumpForces = Vector3.zero;
if (grounded)
{
jumpForces = Vector3.up * jumpForce;
}
rb.AddForce(jumpForces, ForceMode.VelocityChange);
sliding.StopSlide();
this is jump btw
can you try canceling the scaling of the sliding for now?
dont make it scale up or down
maybe it scales up and hits the ground? not sure
Alr lemme try turning 4bat off
But do u think it has anything to do with forces or rigid body
Cus from my understanding it would conserve to an extent
Disregarding friction
I'm not sure how the collision works but if it goes inside ground for a moment
it would stop as it's inside an object so can't move
now thats weird
maybe I need to configure sm with the rigid body i have no idea
whats weird is im adding a force, not changing the velocity so I would expect that to work
is there anywhere where i coild view settings for the physics engine
edit>project settings> physics
you can change the friction value but even it fixes it, it's still a weird problem
ye. If u figure out why, lmk. Thanks tho
can you send me the script files related to movement and sliding?
okay its so weird
its not what I think it is
void Move()
{
Vector3 currentVelocity = rb.velocity;
Vector3 targetVelocity = new Vector3(move.x, 0, move.y);
targetVelocity *= speed;
//Align Direction
targetVelocity = transform.TransformDirection(targetVelocity);
//Calculate forces on player
Vector3 velocityChange = (targetVelocity - currentVelocity);
velocityChange = new Vector3(velocityChange.x, 0, velocityChange.z);
//limit force (just in case)
Vector3.ClampMagnitude(velocityChange, maxForce);
rb.AddForce(velocityChange, ForceMode.VelocityChange);
}
something wrong with movement and velocity change
Do u know what I would change
not yet
if (Input.GetKeyDown(KeyCode.G))
{
rb.AddForce(transform.forward, ForceMode.VelocityChange);
}
I added something like this to test
when I cancel the force off the movement and press G, it moves and doesnt stop
but when I have the force of the player, even when I dont press the button it stops
I guess its because of this
//Calculate forces on player
Vector3 velocityChange = (targetVelocity - currentVelocity);
velocityChange = new Vector3(velocityChange.x, 0, velocityChange.z);
when you release the button, the current value is more then the target value
so it gives the player a force in negative direction
Ohhh shoot I can see that
when I change the velocityChange with targetVelocity inside the force, it doesn't stop
but that part is also important to prevent player from getting infinite speed
I would use rb.velocity btw
this is the one I made and normaly use
you can change the speed up and speed down acceleration independently
you can check it if you like
what do the input numbers for x and y represent
the direction that player will move
wait so How can I fix my code for it to work properly
@jagged token
I'm not sure actually you need that part to stop the player
maybe if you could lower it's effect more by dividing?
alr i see what the problem might be
ima try reworking
the movement entirely
ill come back to u
I'm not sure if it will work but where you do velocity change maybe you can make it /2 when it's <0
so it will apply less force when it's slowing down
the problem is whenever any force is added the player kinda just teleports
what does rb.velocity do
like what this do