コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        float v = MultiPlatformInput.GetAxis("Vertical");
        float h = MultiPlatformInput.GetAxis("Horizontal");

        if (!isWalking)
        {
            if (v != 0 || h != 0)
            {
                Debug.Log("True");
                BotAnimator.SetBool("Walking", true);
                isWalking = true;
            }
        }
        else
        {
            if (v == 0 && h == 0)
            {
                Debug.Log("false");
                BotAnimator.SetBool("Walking", false);
                isWalking = false;
            }
        }
        transform.Translate(new Vector3(h, 0, v) * speed);
    }
コード例 #2
0
    public void FixedUpdate()
    {
        _position = transform.position;
        if (!isDead)
        {
            float motor    = maxMotorTorque * MultiPlatformInput.GetAxis("Vertical");
            float steering = maxSteerAngle * MultiPlatformInput.GetAxis("Horizontal");
            if (Input.GetButton("Jump"))
            {
                isBraking = true;
            }
            else
            {
                isBraking = false;
            }


            currentSpeed = carRigidBody.velocity.magnitude * 3.6f;

            foreach (AxleInfo axleInfo in axleInfos)
            {
                if (axleInfo.steering)
                {
                    axleInfo.SteerAngle = steering;
                }
                if (axleInfo.motor)
                {
                    if (!isBraking)
                    {
                        axleInfo.MotorTorque = motor;
                        axleInfo.BrakeTorque = 0;
                    }
                    else
                    {
                        axleInfo.MotorTorque = 0;
                        axleInfo.BrakeTorque = brakingTorque;
                    }
                }
                axleInfo.ApplyLocalPositionToVisuals();
                //axleInfo.UpdateFriction();
            }
            mapGenerator.UpdateMinimap(position, transform.eulerAngles);


            // Update the current index
            _index = mapGenerator.WorldPointToMapIndex(position);

            fuel -= FuelPerSec * Time.fixedDeltaTime;
        }
    }