- Home /
How can I edit the Charactermotor to slide on tagged objects rather than being over the slope limit.
Hello,
In the charactermotor script I have noticed that sliding only occurs if the character is over the slope limit. I have found the function for that on line 553 - 555,
function TooSteep () {
return (groundNormal.y <= Mathf.Cos(controller.slopeLimit * Mathf.Deg2Rad));
}
How can I change that in order to make it slide on tagged objects instead?
Any help is appreciated. Thank you for your help.
Answer by ghaddar0292 · May 15, 2013 at 10:42 AM
I have fixed this issue by editing couple of lines, If anyone has this problem contact me so I can hand the script to you.
I think the friendly thing to do is to share the solution with the community.
What was I thinking??? I have this problem. Can you share your solution?
yes, so on line 469 replace the function onControllerColliderhit by the following:
function OnControllerColliderHit (hit : ControllerColliderHit) {
if (hit.normal.y > 0 && hit.normal.y > groundNormal.y && hit.moveDirection.y < 0) {
if ((hit.point - movement.lastHitPoint).sqr$$anonymous$$agnitude > 0.001 || lastGroundNormal == Vector3.zero)
groundNormal = hit.normal;
else
groundNormal = lastGroundNormal;
movingPlatform.hitPlatform = hit.collider.transform;
movement.hitPoint = hit.point;
movement.frameVelocity = Vector3.zero;
var body : Transform = hit.transform;
if(body.tag == "Slide"){
TooSteep = true;
}
else{
TooSteep = false;
}
}
}
And then remove the function TooSteep() from the lines 553 - 555 completely. And then ctrl+f TooSteep, you should find that the function TooSteep() is called 3 times, you just need to replace it by the boolean TooSteep. Also do not forget to define the TooSteep as a global boolean variable. I did that over the function oncontrollercolliderhit.
When testing make sure your tagged object is "Slide".
If any problems recontact me.
Your answer
Follow this Question
Related Questions
How do I make my camera follow selected player? 0 Answers
How to make a 2D character stop sliding? 2 Answers
Character Motor Script Corrupted 1 Answer
How to slide a character in temple run like game? 1 Answer
Fixing CharacterMotor 0 Answers