Having a little trouble keeping my character in one place but this code just won’t be accepted by Unity.
var friction = false;
function OnTriggerEnter(collider : Collider){
if(collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
{
friction = true;
this.dynamicFriction = 1;
}
}
friction can’t be turned on and off like that- you can do something cheatery like using
rigidbody.drag = 100;
while you are on the ground. On the other hand, this will make it really hard to move your character- so you’ll have to deactivate it when you are receiving inputs. (just do something like rigidbody.drag = Mathf.Lerp(100, 0, inputVector.magnitude))
Otherwise, for actual friction values, you need to use
collider.material.dynamicFriction = whatever;
since ‘this’ refers to the current script, which doesn’t have such a value (and even if it did, almost certainly wouldn’t do what you wanted it to do).