跳转至

MobCollidePoint 角色与点碰撞

格式

MobCollidePoint(mobId, point)

简介

判断角色是否与坐标位置碰撞。

参数

名称 类型 描述
mobId int 角色ID
point Vec3 坐标位置

返回值

名称 类型 描述
isCollide bool 是否与坐标位置碰撞,True为碰撞,False为未碰撞

实例

按下鼠标左键时打印角色mob是否与坐标位置(0,25,0)碰撞。

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:
        print(wx.MobCollidePoint(mob.id, vmath.Vec3(0, 25, 0)))

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