代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。

原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html



一一八.机器可携带

	1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/scienceprototyper.lua文件,将MakeObstaclePhysics(inst, .4)替换为以下内容:

local function turnon(inst)
	inst.components.machine.ison = true
	inst:AddComponent("inventoryitem")
end
local function turnoff(inst)
	inst.components.machine.ison = false
	inst:RemoveComponent("inventoryitem")
end
	inst:AddComponent("machine")
	inst.components.machine.turnonfn = turnon
	inst.components.machine.turnofffn = turnoff
	inst:AddComponent("equippable")


	2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/magicprototyper.lua文件,将MakeObstaclePhysics(inst, .4)替换为以下内容:

local function turnon(inst)
	inst.components.machine.ison = true
	inst:AddComponent("inventoryitem")
end
local function turnoff(inst)
	inst.components.machine.ison = false
	inst:RemoveComponent("inventoryitem")
end
	inst:AddComponent("machine")
	inst.components.machine.turnonfn = turnon
	inst.components.machine.turnofffn = turnoff
	inst:AddComponent("equippable")

	即可在机器上按鼠标右键解除固定,再按鼠标左键点击即可带在身上。想固定机器时,将机器放在地上,在机器上按鼠标右键即可固定在地上