// Update is called once per frame
    public override void FixedUpdate()
    {
        float deltaTime = Time.fixedDeltaTime;

        AddForce(ForceGenerator3D.GenerateForce_Gravity(Mass, m_Gravity, Vector3.up));
        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.E))
        {
            AddThrust(deltaTime, new Vector3(-m_ThrusterDistFromCenter, 0));
        }
        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.E))
        {
            AddThrust(deltaTime, new Vector3(m_ThrusterDistFromCenter, 0));
        }
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.E))
        {
            AddThrust(deltaTime, new Vector3(0, 0, m_ThrusterDistFromCenter));
        }
        if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.E))
        {
            AddThrust(deltaTime, new Vector3(0, 0, -m_ThrusterDistFromCenter));
        }
        if (m_LastContact != null)
        {
            HandleJustCollided(deltaTime);
            m_LastContact = null;
        }

        if (Vector3.Dot(transform.up, Vector3.up) < 0 && m_LastContact == null)
        {
            m_UpsidedownSinceContact = true;
        }

        base.FixedUpdate();
    }
Beispiel #2
0
    public override void FixedUpdate()
    {
        Vector3 surfNorm = new Vector3(0.1f, 1.0f, 0.0f).normalized;

        Debug.DrawRay(Vector3.zero, surfNorm);
        Vector3 gravForce = ForceGenerator3D.GenerateForce_Gravity(Mass, -9.81f, Vector3.up);

        AddForce(gravForce);
        Vector3 normForce = ForceGenerator3D.GenerateForce_Normal(gravForce, surfNorm);

        AddForce(normForce);
        Vector3 frictionForce = ForceGenerator3D.GenerateForce_Friction_Static(surfNorm, -surfNorm, 0.8f);

        //AddForceAtPoint(frictionForce);
        base.FixedUpdate();
    }