0 Favourites

How do I create and track weapons to origin points

  • Hello,

    I tried to search through the forum but was not able to really get anywhere I might be looking for something to specific or bad at searching so if the answer is somewhere and I was unable to find it I apologize.

    I am currently trying to have the enemy's in my game spawn a weapon, swing said weapon and have it move to the position of the origin point I have set for the animation then destroy itself when the animation is done.

    I currently have

    enemy(sprite), Is in animation "Attack"(the animation)

    is not "equipped" (Boolean)

    create object "weapon"(sprite) on layer 1 at enemy.imagepointx("attack"),enemy.imagepointy("attack")

    set "match"(variable on the weapon sprite) to enemy.UID

    set "equipped"(Boolean) to false

    separate event

    enemy(sprite), pick instance with UID "match"(variable on the weapon sprite)

    "weapon"(sprite), "match"(variable on the weapon sprite) = enemy.UID

    set position to enemy.imagepointx("attack"),enemy.imagepointy("attack")

    These are the only two events I have that affect the position and it works great when there is only one enemy but as soon as I have 2 or more one of the weapons tends to start being off by 20-40pixels or so. Any clues why it might be doing that?

    Should I find a better way to link the weapons to the enemy's aside from UID?

    Sorry if anything does not make sense.

    (I did try using pin as well thinking it would be easier but it wasn't able to follow the origin point as it changes through the animation)

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)