Untiy3d 铰链、弹簧,特殊的物理关节

(一)铰链组件

1.创建一个立方体和角色胶囊

2.给角色胶囊挂在控制脚本和刚体

csharp 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class plyer : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        // 水平轴
        float horizontal = Input.GetAxis("Horizontal");
        // 垂直轴
        float vertical = Input.GetAxis("Vertical");
        // 向量
        Vector3 dir = new Vector3(horizontal, 0, vertical);
        // 朝向范方向移动
        transform.Translate(dir * 2 * Time.deltaTime);



    }
}

4.给立方体挂载刚体Rigidbody和铰链Hinge Joint组件

效果

untiy 3d 弹簧组件

(二)弹簧组件

1.创建2个立方体

2.给2个立方体挂在刚体组件

3.给上面的立方体挂在弹簧组件并给上面的立方体设置是运动学防止掉下来


运行效果

untiy 3d 弹簧组件

相关推荐
薛晓刚几秒前
MySQL的replace使用分析
android·adb
DengDongQi23 分钟前
Jetpack Compose 滚轮选择器
android
stevenzqzq24 分钟前
Android Studio Logcat 基础认知
android·ide·android studio·日志
代码不停33 分钟前
MySQL事务
android·数据库·mysql
朝花不迟暮38 分钟前
使用Android Studio生成apk,卡在Running Gradle task ‘assembleDebug...解决方法
android·ide·android studio
yngsqq1 小时前
使用VS(.NET MAUI)开发第一个安卓APP
android·.net
Android-Flutter1 小时前
android compose LazyVerticalGrid上下滚动的网格布局 使用
android·kotlin
Android-Flutter1 小时前
android compose LazyHorizontalGrid水平滚动的网格布局 使用
android·kotlin
学無芷境1 小时前
vesselFM: A Foundation Model for Universal 3D Blood Vessel Segmentation
3d
千里马-horse1 小时前
RK3399E Android 11 将自己的库放到系统库方法
android·so·设置系统库