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 弹簧组件

相关推荐
2601_949543013 小时前
Flutter for OpenHarmony垃圾分类指南App实战:主题配置实现
android·flutter
2601_949833394 小时前
flutter_for_openharmony口腔护理app实战+知识实现
android·javascript·flutter
晚霞的不甘4 小时前
Flutter for OpenHarmony从基础到专业:深度解析新版番茄钟的倒计时优化
android·flutter·ui·正则表达式·前端框架·鸿蒙
鸟儿不吃草5 小时前
android的Retrofit请求https://192.168.43.73:8080/报错:Handshake failed
android·retrofit
Minilinux20185 小时前
Android音频系列(09)-AudioPolicyManager代码解析
android·音视频·apm·audiopolicy·音频策略
李子红了时5 小时前
【无标题】
android
图生生6 小时前
基于AI的电商产品2D转3D,降低3D建模开发成本
3d·ai
Android系统攻城狮6 小时前
Android tinyalsa深度解析之pcm_close调用流程与实战(一百零四)
android·pcm·tinyalsa·音频进阶·音频性能实战·android hal
weixin_411191846 小时前
LifecycleEventObserver和DefaultLifecycleObserver使用
android
、BeYourself7 小时前
Intent :跳转与数据传递的正确打开方式
android·android-studio