unity3d - How to Edit the character motor script to enable slide on tagged objects rather than it is greater than slope limit? -
i working on 2.5d platforming game on unity3d , need character slide on tagged objects rather being on slope limit. using character motor , fps input scripts.
have found line enables slide , follows:
function toosteep () { return (groundnormal.y <= mathf.cos(controller.slopelimit * mathf.deg2rad)); }
this condition on slope limit, how able edit function return true if game object character on tagged "slide" example.
appreciated thank much.
first, add new boolean field charactermotor script , throw in "or" in if statement checks if player grounded and if ground steep, looks this:
if(grounded && (toosteep() || somenewbool))
then, attach trigger box collider object (don't bother tags on other object), , attach monobehaviour following function in it:
function ontriggerenter(other:collider) { if(other.tag.equals("player"))//replace "player" tag marked player with. { other.getcomponent(charactermotor).somenewbool = true;// new bool added charactermotor script } }
and function looks this:
function ontriggerexit(other:collider) { if(other.tag.equals("player")) { other.getcomponent(charactermotor).somenewbool = false; } }
Comments
Post a Comment