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

相关推荐
CV资深专家3 小时前
Android 基础入门学习目录(持续更新)
android
侧耳4293 小时前
android添加i2c-tools工具
android
我是好小孩7 小时前
Android-侧边导航栏的使用
android·gitee
吗喽对你问好7 小时前
安卓基础布局核心知识点整理
android·gitee
安卓开发者7 小时前
Android Material Components 全面解析:打造现代化 Material Design 应用
android
教程分享大师7 小时前
带root权限_中国移动创维DT541_S905L3融合机器改机顶盒刷机教程 当贝纯净版安卓9.0系统线刷包 刷机包
android
wuk9987 小时前
Android:UI:Drawable:View/ImageView与Drawable
android·ui
whysqwhw8 小时前
Kotlin 中作用域函数 let、with、run、also、apply 的核心使用指南
android
旋风菠萝9 小时前
设计模式---单例
android·java·开发语言
whysqwhw10 小时前
Android Jetpack 中 ViewModel 的全面解析
android