用户:
黑马程序员查看:4 回复:2 评论:4 创建时间:2022-01-25T22:26:13
就是让玩家碰到模型后变成模型的代码
for (const e of world.querySelectorAll('#船')) {
e.collides = true //实体可以被碰撞
e.fixed = true //实体固定位置
e.onEntityContact(({ other }) => {
if (other.isPlayer) { // 如果跟当前实体碰撞的是玩家实体
other.player.invisible = true // 玩家皮肤隐藏
other.mesh = e.mesh // 玩家的外形换成当前实体的外形
other.meshScale.copy(e.meshScale) // 玩家外形的缩放比例设成跟当前实体一样
other.player.scale = e.meshScale.scale(e.bounds.y / other.bounds.y) //玩家的隐形碰撞盒缩放到模型刚好贴地
}
})
}点赞1
评论
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
点赞0
评论