#yes

1 messages · Page 1 of 1 (latest)

jagged token
#

Can you send a short video of the problem?

hardy hawk
#

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

hardy hawk
jagged token
# hardy hawk Yes

and does it also happen when you just stop sliding and not jumping?

hardy hawk
#

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

jagged token
#

dont make it scale up or down

#

maybe it scales up and hits the ground? not sure

hardy hawk
#

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

jagged token
#

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

hardy hawk
#

even without the scale

#

it doesnt work

jagged token
#

now thats weird

hardy hawk
#

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

jagged token
#

you can change the friction value but even it fixes it, it's still a weird problem

hardy hawk
#

ye. If u figure out why, lmk. Thanks tho

jagged token
jagged token
#

you use wrong force mode

hardy hawk
#

What do I change

#

@jagged token

jagged token
#

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

hardy hawk
#

Do u know what I would change

jagged token
#

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

hardy hawk
#

I’ll try it

#

Thanks

jagged token
#

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

hardy hawk
#

Ohhh shoot I can see that

jagged token
#

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

hardy hawk
#

what do the input numbers for x and y represent

jagged token
hardy hawk
#

@jagged token

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?

hardy hawk
#

alr i see what the problem might be

#

ima try reworking

#

the movement entirely

#

ill come back to u

jagged token
#

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

hardy hawk
#

the problem is whenever any force is added the player kinda just teleports

#

what does rb.velocity do

hardy hawk