福感科技有限公司 欢迎您!
联系方式

    地址:北京市平谷区马坊镇金河北街17号院3号楼7层712

    电话:010-89968230

    网站:http://www.fgsense.com

如何在unity3d中给物体增加扭矩力

2020-12-11 20:49:19      点击:
using UnityEngine;
using System.Collections;

public class AddTorqueExample : MonoBehaviour
{
    public float amount = 50f;
    
    
    void FixedUpdate ()
    {
        float h = Input.GetAxis("Horizontal") * amount * Time.deltaTime;
        float v = Input.GetAxis("Vertical") * amount * Time.deltaTime;
        
        rigidbody.AddTorque(transform.up * h);
        rigidbody.AddTorque(transform.right * v);
    }
}

Copyright 2019 www.fgsense.com

福感科技有限公司 版权所有 All Rights Reserved

京ICP备20002031号

010-89968230