Hi, I’m sorry I didn’t answer for so long. The console does not throw errors, I cannot show the code in full due to some bug fixes. In fact, this is the only problem. I can throw you the current code, but it uses some kind of crutch. As I understand it, the problem is that the engine considers some objects to be 1. By calling the msg.url (".") Function on both objects, we get the same thing (ending instance0), although it should be (instance0 and instance1)
local isActivate = false;
local rot;
local maxRot;
local minRot;
local fire = false;
local canFire = true
local plr;
local force = 1500
function init(self)
msg.post(".", "acquire_input_focus")
rot = go.get_rotation();
maxRot = rot.z+45
minRot = rot.z-45
end
function update(self, dt)
if(isActivate)then
if(-math.deg(go.get_rotation().z) <= -21.9)then
go.cancel_animations(".", "rotation")
go.animate(".", "euler.z", go.PLAYBACK_ONCE_FORWARD, minRot, go.EASING_LINEAR, 2)
elseif(math.deg(go.get_rotation().z) <= -21.9)then
go.cancel_animations(".", "rotation")
go.animate(".", "euler.z", go.PLAYBACK_ONCE_FORWARD, maxRot, go.EASING_LINEAR, 2)
end
if(fire and canFire)then
local angle = go.get_rotation().z*2
local _pos = vmath.vector3(go.get_position().x+50*math.cos(angle)*force,go.get_position().y+50*math.sin(angle)*force,0)
--msg.post("@render:", "draw_line", { start_point = go.get_position(), end_point = _pos, color = vmath.vector4(1,0,0,1) })
local col1 = plr;
local col2 = plr;
col1.fragment = "canCol"
col2.fragment = "collisionobject"
local myCol
myCol = msg.url()
myCol.fragment = "cannon"
--go.delete(myCol)
myCol.fragment = "cannonCol"
msg.post(myCol, "disable")
msg.post(col1, "enable")
msg.post(col2, "enable")
fire = false
canFire = false
msg.post(col2, "apply_force",{force = _pos,position = go.get_position()})
go.cancel_animations(".", "euler.z")
particlefx.play("#cannonFire")
isActivate = false
local plrUrS = plr
plrUrS.fragment = "ball"
msg.post("/ball#ball", "enableCol")
--go.delete(".")
end
end
--print(go.get_rotation())
end
function on_message(self, message_id, message, sender)
if(message_id == hash("inCannon"))then
isActivate = true;
plr = sender
go.set_position(go.get_position(),sender)
go.animate(".", "euler.z", go.PLAYBACK_ONCE_FORWARD, minRot, go.EASING_LINEAR, 1)
canFire = true
end
end
function on_input(self, action_id, action)
if(action_id == hash("interactive") and canFire == true)then
if(action.released)then
fire = true;
end
end
end