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

相关推荐
执明wa3 小时前
LayoutInflater详解: XML是如何变成View的?
android·xml·开发语言·android studio
404_coder3 小时前
源码视角下的 Android 开机流程:从 Zygote、SystemServer 到 Launcher
android
二流小码农4 小时前
鸿蒙开发:以登录案例了解代码架构MVVM
android·ios·harmonyos
用户69371750013844 小时前
从代码生产者到 AI 协作者:软件工程师的角色重构
android·前端·后端
GitLqr5 小时前
别在 Flutter 的 main() 里乱锁屏幕方向,小心 iPad 分屏功能被你搞没了
android·flutter·ios
sg_knight5 小时前
MySQL 存储过程详解:从入门到实战
android·数据库·mysql·database·dba·关系型数据库·db
爱笑鱼5 小时前
Binder(四):ioctl(BINDER_WRITE_READ) 之后,事务怎样到达目标进程?
android
AFinalStone5 小时前
Android 7系统休眠唤醒(二)开机全链路—BootROM到Launcher
android·电源管理·休眠唤醒
Mr YiRan5 小时前
Android NDK开发之统计到未被回收的图片
android