0 Favourites

How do I fix "Create Object in a wrong place"?

  • Hello bro, I'm new in Construct2

    I try to do "drop item after kill enemies"

    So I just program like this

    Bullet:On collision with enemy>Create "potion" at enemy.x,enemy.y>destroy enemy

    However, potions don't appear at the right place, instead, potion appears forward/backward the point

    What's wrong with my coding? I saw other tutorials and they both do like this...

  • Check your imagepoint on the enemy sprite it may be in a weird spot. Also add a wait=0 before the destroy enemy in case it is destroying the enemy before it can spawn potion.

  • chrisinfinger

    Wait 0 is not needed, and, in fact it may result in potion being spawned twice if another bullet hit the enemy in next tick.

    Object is not destroyed until the end of the tick, so even if you change the order of actions (destroy enemy -> Create "potion" at enemy.x,enemy.y) , it will still work.

  • Check your imagepoint on the enemy sprite it may be in a weird spot. Also add a wait=0 before the destroy enemy in case it is destroying the enemy before it can spawn potion.

    The imagepoint on enemies is "Origin", I don't change or set another imagepoint on them.

    I wonder if the behavior "Bullet" on enemies has any relations to this bug, but in my teammates' projects this can work too.

    Currently, I just test the distance between enemies and the point which potion creates, let the code increase/decrease the number of x and fix this bug.

    Although I still wonder why this bug happened, both of my and my teammates' code are the same.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Try changing the potion drop location to the bullets x,y position when it is destroyed and see if that works right.

    Also, you could try having the bullet spawn the potion in its events before it is destroyed to see if that works.

    Your code "should" be working right, something is going sideways obviously.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
175 32,634
clifton11221's avatar
clifton11221
Unread hot topic
99 10,137
karshinkoff's avatar
karshinkoff
Unread hot topic
167 14,491
DMT2005's avatar
DMT2005