跳转至

MobSetMotion

格式

MobSetMotion(mobId, motion, speed, angularSpeed)

简介

设置角色运动。运动类型详见MOTION

参数

名称 类型 描述
mobId int 角色ID
motion key 运动类型
speed float 移动速度
angularSpeed float 转动速度

实例

按下鼠标左键时设置角色mob以移速1转速0.5做向前移动运动。

import fg
import wx
import vmath

asset = fg.AssetCreate()
asset.name = 'Main Scene'
asset.state = fg.STATE.VOXMODEL
asset.vmFile = 'mainScene'
asset.icon='icon.png'

fg.AssetRegister(asset)

mob = fg.AssetCreate()
mob.name = 'mob'
mob.state = fg.STATE.MOBILE
mob.mobSkeleton = 'skeleton.ozz'
mob.mobMesh = 'mesh.ozz'
mob.mobTexture = 'texture.png'
mob.mobAction = 'action.ozz'
mob.icon='mob.png'

def onStart(self):
    global mob
    mob=fg.AssetBuildEntity(fg.AssetRegister(mob), self.id, vmath.Vec3(0, 25, 0))

def onmouse(self, stamp, button, action, mods):
    if button==wx.MOUSE_BUTTON.LEFT and action==wx.ACTION.PRESS:
        wx.MobSetMotion(mob.id, wx.MOTION.FORWARD, 1, 0.5)

fg.AssetSetStartCBFunc(asset, onStart)
fg.AssetSetMouseButtonCBFunc(asset, onmouse)