I tried to make a spear like Terraria but I need some help. I made it and it works perfectly, except it won't stay with the player. Here is the code:
+ Inv_Box: Item_Type = "Spear"
----+ (no conditions)
-----> Player_Parts: Set Swinging to True
-----> Player_Arm: Set animation to Dictionary.Get("Armor") & "_Swing" (play from beginning)
-----> Player_Arm: Set animation speed to 0
----+ (no conditions)
-----> System: Create object Player_Weapon on layer "Objects" at (Player_Arm.ImagePointX("Weapon"), Player_Arm.ImagePointY("Weapon"))
-----> Player_Weapon: Set Type to "Spear"
-----> Player_Weapon: Set angle toward (Mouse.X, Mouse.Y)
-----> Player_Weapon: Move behind Player_Arm
-----> Player_Weapon: Set animation to Inv_Box.AnimationName (play from beginning)
-----> Player_Weapon: Set animation frame to Inv_Box.AnimationFrame
-----> Player_Weapon: Set Damage to Dictionary.Get("Damage") + int(random(-3, 3))
-----> Player_Weapon: Set KnockBack to Inv_Box.KnockBack
-----> Player_Weapon: Set Speed to Inv_Box.Speed
-----> Player_Weapon: Start Timer "Thrust" for ((25 - Self.Speed) ÷ 10) ÷ 3.5 (Once)
--------+ (no conditions)
---------> System: Wait for previous actions to complete
------------+ Player_Weapon: Is between 270 and 295 degrees
-------------> Player_Weapon: Set angle to Self.Angle + 45 degrees
-------------> Player_Arm: Set animation frame to 0
-------------> Player_Parts: Set Not mirrored
------------+ System: Else
------------+ Player_Weapon: Is between 295 and 345 degrees
-------------> Player_Weapon: Set angle to Self.Angle + 45 degrees
-------------> Player_Arm: Set animation frame to 1
-------------> Player_Parts: Set Not mirrored
------------+ System: Else
------------+ Player_Weapon: Is between 345 and 65 degrees
-------------> Player_Weapon: Set angle to Self.Angle + 45 degrees
-------------> Player_Arm: Set animation frame to 2
-------------> Player_Parts: Set Not mirrored
------------+ System: Else
------------+ Player_Weapon: Is between 65 and 90 degrees
-------------> Player_Weapon: Set angle to Self.Angle + 45 degrees
-------------> Player_Arm: Set animation frame to 3
-------------> Player_Parts: Set Not mirrored
------------+ System: Else
------------+ Player_Weapon: Is between 250 and 270 degrees
-------------> Player_Weapon: Set angle to Self.Angle - 45 degrees
-------------> Player_Arm: Set animation frame to 0
-------------> Player_Parts: Set Mirrored
-------------> Player_Weapon: Set Flipped
------------+ System: Else
------------+ Player_Weapon: Is between 200 and 250 degrees
-------------> Player_Weapon: Set angle to Self.Angle - 45 degrees
-------------> Player_Arm: Set animation frame to 1
-------------> Player_Parts: Set Mirrored
-------------> Player_Weapon: Set Flipped
------------+ System: Else
------------+ Player_Weapon: Is between 115 and 200 degrees
-------------> Player_Weapon: Set angle to Self.Angle - 45 degrees
-------------> Player_Arm: Set animation frame to 2
-------------> Player_Parts: Set Mirrored
-------------> Player_Weapon: Set Flipped
------------+ System: Else
------------+ Player_Weapon: Is between 90 and 115 degrees
-------------> Player_Weapon: Set angle to Self.Angle - 45 degrees
-------------> Player_Arm: Set animation frame to 3
-------------> Player_Parts: Set Mirrored
-------------> Player_Weapon: Set Flipped
The last part is just to make the arm line up with the angle of the spear (https://www.construct.net/en/forum/construct-3/how-do-i-8/shooting-problems-146513?kws=)
I need it to stay at the player's image point "Weapon." The problem is that I can't use 'every tick -> set position to. . ., or the pin behavior because the spear actually moves. I don't want to do animations. Any suggestions on how to make the spear stay with the player? It needs to set position to his image point, but also the offset of the movement and angle of the spear.
Thanks,
Give me a Pixel