示例#1
0
    public void FixedUpdate()
    {
        float motor    = maxMotorTorque * Input.GetAxis("VerticalKey");
        float steering = maxSteeringAngle * Input.GetAxis("HorizontalKey");

        foreach (AxleInfo axleInfo in axleInfos)
        {
            if (axleInfo.steering)
            {
                axleInfo.leftWheel.steerAngle  = steering;
                axleInfo.rightWheel.steerAngle = steering;
            }
            if (axleInfo.motor)
            {
                axleInfo.leftWheel.motorTorque  = motor;
                axleInfo.rightWheel.motorTorque = motor;
            }
        }

        if (Input.GetKeyDown("space"))
        {
            Quaternion rot = transform.rotation;
            rot.eulerAngles.Set(rot.x, rot.y, 0);
            transform.rotation = rot;
        }

        m_healthManager.AddDistanceTravelled(Mathf.Abs((transform.position - m_lastPos).magnitude));
        m_lastPos = transform.position;
    }
示例#2
0
    void Move()
    {
        var x = Input.GetAxis("Horizontal") * Time.deltaTime * RotationSpeed;
        var z = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * ForwardSpeed;

        transform.Rotate(0, x, 0);
        transform.position += z;

        m_healthManager.AddDistanceTravelled(z.magnitude);

        //rb.velocity = transform.TransformDirection(5 * Vector3.forward * ForwardSpeed * Input.GetAxis("Vertical"));
    }