代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
1
2二七0.筋斗云(按键盘Z键召唤筋斗云在天上飞行,再按Z键落地)
3
4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("resurrectable")的下一行插入以下内容:
5
6TheInput:AddKeyUpHandler(KEY_Z, function()
7 if not inst:HasTag("flycloud") then
8 inst:AddTag("flycloud")
9 inst.components.locomotor:Stop()
10 inst.components.talker:ShutUp()
11 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())
12 inst.AnimState:PlayAnimation("give")
13 inst:DoTaskInTime(0.3, function()
14 inst.cloud = SpawnPrefab("corn_cooked")
15 inst.cloud.Physics:SetActive(false)
16 inst.cloud.Transform:SetScale(1.8, 1.8, 1.8)
17 inst.cloud.AnimState:SetMultColour(255/255,255/255,255/255,0.6)
18 inst.cloud.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
19 inst.cloud:RemoveComponent("perishable")
20 inst.cloud:RemoveComponent("edible")
21 inst.cloud:RemoveComponent("stackable")
22 inst.cloud:RemoveComponent("inventoryitem")
23 inst.cloud:RemoveComponent("bait")
24 inst.cloud:RemoveComponent("tradable")
25 inst.cloud:RemoveComponent("burnable")
26 inst.cloud:RemoveComponent("propagator")
27 inst.cloud.persists = false
28 inst.cloud:AddTag("NOCLICK")
29 local follower = inst.cloud.entity:AddFollower()
30 follower:FollowSymbol( inst.GUID, "swap_body", 0, 60, 0 )
31 local pt = inst:GetPosition()
32 inst.Transform:SetPosition(pt.x, 10, pt.z)
33 local shadow = inst.entity:AddDynamicShadow()
34 shadow:SetSize( 0, 0 )
35 inst.gogogo = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(25,1.5,0) end)
36 end )
37 else
38 inst:RemoveTag("flycloud")
39 inst.components.locomotor:Stop()
40 inst.components.talker:ShutUp()
41 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())
42 inst.AnimState:PlayAnimation("give")
43 inst:DoTaskInTime(0.3, function()
44 if inst.cloud then inst.cloud:Remove() inst.cloud = nil end
45 if inst.gogogo then inst.gogogo:Cancel() inst.gogogo = nil end
46 local pt = inst:GetPosition()
47 inst.Transform:SetPosition(pt.x, 0, pt.z)
48 local shadow = inst.entity:AddDynamicShadow()
49 shadow:SetSize( 1.3, .6 )
50 inst.Physics:ClearMotorVelOverride()
51 inst.Physics:ClearMotorVelOverride()
52 end )
53 end
54end )
55
56 即可口中默念咒语——“走你”,并按下键盘Z键,召唤筋斗云在天上飞行,用键盘W、S、A、D键控制方向,再次按Z键可落地