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

Get help using Construct 2

Post » Thu Mar 15, 2018 1:36 pm

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...
B
2
Posts: 2
Reputation: 154

Post » Thu Mar 15, 2018 3:04 pm

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.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
81
S
22
G
8
Posts: 664
Reputation: 10,333

Post » Fri Mar 16, 2018 12:06 am

@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.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
156
Posts: 2,208
Reputation: 82,997

Post » Thu Mar 22, 2018 2:14 am

chrisinfinger wrote: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.
B
2
Posts: 2
Reputation: 154

Post » Thu Mar 22, 2018 10:24 pm

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.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
81
S
22
G
8
Posts: 664
Reputation: 10,333


Return to How do I....?

Who is online

Users browsing this forum: grigrizljac and 4 guests