Forum rules - please read before posting.

physics and gravity.

Hi, I have a new suggestion regarding physics and gravity. I'd like to have the friction value to be changeable based on the movement detection. For example, when player is idle, the physic material change to max friction so he doesn't get pushed by other objects such as monsters, doors or also sliding through stairs and when he walks or runs the physic material changes to minimum friction so when he walks he doesn't get stuck near walls.

Comments

  • I feel this is too specific a behaviour to be a setting within the Player component, but you could achieve this with a simple add-on script, e.g.:

    using UnityEngine;
    using AC;
    
    public class ChangeCharacterPhysics : MonoBehaviour
    {
    
        [SerializeField] private PhysicMaterial idleMaterial = null;
        [SerializeField] private PhysicMaterial moveMaterial = null;
    
        private AC.Char character;
        private Collider _collider;
    
    
        void Start ()
        {
            character = GetComponent <AC.Char>();
            _collider = GetComponent <Collider>();
        }
    
    
        void Update ()
        {
            if (character.charState == CharState.Idle)
            {
                _collider.material = idleMaterial;
            }
            else
            {
                _collider.material = moveMaterial;
            }
        }
    
    }
    
  • Thanks Chris, It worked, but I'll do more testing.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.