Skip to content

Model

继承自

描述

模型节点

属性

DimensionUnitDimensionUnit
模型尺寸
MaterialTemplateMaterialType
材料类型
ModelAssetTypeTextureId
设置模型的材质,即资源id
ColorQuadColor
模型的颜色
ModelAssetTypeModelId
模型id,即资源id
floatGravity
模型重力
floatFriction
模型摩擦力
floatRestitution
模型反弹力,比如物体撞击在地面上会根据此值来计算反弹高度
floatMass
模型质量
Vector3Velocity
模型移动速度
Vector3AngleVelocity
模型角速度
Vector3Size
模型的包围盒大小
Vector3Center
模型的中心点所在世界坐标
boolEnableGravity
模型是否支持重力
boolAnchored
锚定状态,为true时此物体不受外部环境物理影响,但是会给外部提供物理输入。例如:有外来物体撞击到此物体,此物体不会产生移动,但是会对外来物体产生碰撞反弹力。
PhysicsTypePhysXType
物理类型
boolEnablePhysics
开启此物体的物理状态。为true时物体的物理属性可以使用
boolCanCollide
是否可以碰撞。设为false时为trigger状态
boolCanTouch
是否触发碰撞回调函数:Touched和TouchEnded事件
intCollideGroupID
int),可以通过PhysXService:SetCollideInfo函数设置任意两个组之间是否会产生碰撞
CullLayerCullLayer
消隐层
boolIgnoreStreamSync
忽略流同步
boolTextureOverride
材质贴图覆盖
boolCastShadow
是否打开阴影
boolCanRideOn
能否跟着走
boolDrawPhysicsCollider
显示物理包围盒
boolReceiveShadow
是否接受投影
boolCanBePushed

函数

获取动画ID
获取动画骨骼
获取骨骼动画
获取模型动画
获取属性动画
获取骨骼动画
获取人形动画
获取动画制作器
是否加载完成
获取渲染位置
获取渲染旋转
获取渲染欧拉角
获取已经加载的资源类型
开启或关闭动画事件
voidSetAnimationPriority (int seqid, int value)
设置动画优先级
voidSetAnimationWeight (int seqid, float value)
设置动画权重
voidSetBoneRotate (string boneName, Quaternion qua, float scale)
设置骨骼动画旋转
voidAddForce (Vector3 force)
添加力
voidAddTorque (Vector3 torque)
添加扭矩
voidAddForceAtPosition (Vector3 force, Vector3 position, int mode)
添加力位置
voidSetMaterial (string skinMeshRenderCompName, string materialid, int index)
设置材质
voidSetMaterialByNameOrIndex (string findKey, bool byName, bool isSkinMeshRender, int materialIndex, string resId, LuaFunction callback)
设置材质
voidSetMaterialResId (string materialResId)
设置材质资源实例
boolPlayAnimation (string id, float speed, int loop)
播放动画
boolPlayAnimationEx (string id, float speed, int loop, int priority, float weight)
播放动画Ex
停止动画
停止动画Ex
停止所有动画
获取动画优先级
获取动画权重
获取锚点世界坐标(仅脚本可用)
boolIsBinded (bool set)
是否绑定
intSetMaterialNew (string meshRenderCompName, string materialid, int index, LuaFunction callback)
设置材质
SandboxNodeGetMaterialByNameOrIndex (string findKey, bool byName, bool isSkinMeshRender, int materialIndex)
获取材质节点
获取材料实例
通过节点名查询该骨骼节点对象
按名称获取骨骼节点
boolSetAssetContent (SandboxNode arg1, table arg2, int arg3)

事件

模型被其他模型碰撞时,会触发一个Touched通知
模型被其他模型碰撞结束时,会触发一个TouchEnded通知
模型触发动画事件时发送一个AnimationEvent通知
动画帧事件触发
SBXSignalLoadFinish (bool isFinish)
加载完成时触发事件

代码示例

lua
--创建实例
local newModel= SandboxNode.new('Model')
--设置名字
newModel.Name = "my_model"
--设置模型
newModel.ModelId = string.format("sandboxAsset://entity/%s/body.omod","100010")
--设置位置
newModel.Position = Vector3.new(500,700,500)
--设置父节点 将模型节点添加到Workspace中
newModel:SetParent(Workspace)

--播放动画
local player = game:GetService("Players").LocalPlayer.Character
player:PlayAnimation("100114", 1.0, 0, 1, 1.0) --"100114 吃的动作"
player:StopAnimation("100114") --"100114 某个指定动作"