Rigidbody jump script collision help. (562165)

Yes! Adjusting jumpforce helped… One step closer…

Yes despite sliding the jumping near the wall worked properly :wink:

Ok, great to hear! So unless I’m forgetting something, sliding is the only problem you’re experience right now. Well, this subject is slightly complicated, so I’m just going to copy/paste some of the code from my PlayerController here (with a few slight modifications, so mind my typos). A mathematician might laugh at my process, but it works, and is pretty efficient. So here it is:

// align our movement vectors with the ground normal (ground normal = up)
Vector3 targetSpeed = Vector3.Cross(groundNormal, transform.forward) * (Input.GetAxis("Horizontal") * MoveSpeed) + Vector3.Cross(transform.right, groundNormal) * (Input.GetAxis("Vertical") * MoveSpeed);

length = targetSpeed.magnitude;
float difference = length - rigidbody.velocity.magnitude;

// avoid divide by zero
if (Mathf.Approximately(difference, 0.0f))
    movement = Vector3.zero;

else
{
    float acceleration;

    // determine if we should accelerate or decelerate
    if (difference > 0.0f)
        acceleration = Mathf.Min(AccelRate * Time.deltaTime, difference);
    else
        acceleration = Mathf.Max(-DecelRate * Time.deltaTime, difference);

    difference = 1.0f / difference * acceleration;
    movement = new Vector3((targetSpeed.x - rigidbody.velocity.x) * difference, (targetSpeed.y - rigidbody.velocity.y) * difference, (targetSpeed.z - rigidbody.velocity.z) * difference);
}

rigidbody.AddForce(movement, ForceMode.VelocityChange);

You will need to add a few new public variables or rename the ones in my code to match yours:

AccelRate (float)
DecelRate(float)
MoveSpeed (float)

You will also need groundNormal from the SphereCast. Just set groundNormal = hit.normal.

Thank you again for helping me so much, but the problem stays the same, maybe I did add the code in wrong place or maybe we’re talkin about other action. So to be clear here’s the video and code:

As you can see, after I enter at tilted object I begin to slide, forever.

That’s odd. Was the problem the exact same before you added my code? Perhaps AccelRate, DecelRate, and/or MoveSpeed are set to zero?

Also, I noticed you are moving the player in Rotating() with this line: “rigidbody.transform.Translate(Vector3.forward* BaseSpeed);”

This line is odd because it doesn’t use transform.forward, but rather Vector3.forward… try removing that line. It would explain why you move in a constant direction, but not why it only happens after you land on the slope.

public float AccelRate = 5.0f;
public float DecelRate = 5.0f;
public float MoveSpeed = 5.0f;
Made changes and also checked movement with different numbers on them. After I’ve removed the line you’ve asked me to character doesn’t move as it shouldn’t and there is no difference while changing values of Rates and MoveSpeed.

I feel like I need to thank you again for your awesome help!

Hmm it seems as though you are moving the character with the animation and not physics. If you remove the movement code I gave you, I’ll bet your character will still move. If so, then the movement is done through the animation. If you do that, is the behavior desired? I’m not understanding if the sliding issue is still present.

And no problem! I’m glad to help out. I love making Player Controllers, so I just take a break every now and then from working on mine to visit this thread ;).

No. I have disabled animation movement long ago. It wasn’t something I was searching for.

Glad to know. But something tells me we will talk for a loooong time!

So the player is still currently sliding?

Hi!

Don’t know if it will help, but for movement I based my code on this guy code:

http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker

Hope it helps. o/

Yes. It’s sliding after entering not flat surface it slides off and continues sliding.

Hmm, the problem isn’t apparent to me. Is it possible for you to recreate your project without any proprietary assets (never trust anyone on the internet ;)) and just the minimum scripts and a sample scene to reproduce the problem? If so, send it here and I’d be glad to have a go at debugging it. It’s really tough to debug without a bunch of shots in the dark, and I feel that could take a while without the ability to adjust the code myself.

Check PM please.