[Solved] Hotbar/inventory system

I took a quick look at that line. The issue is the plants have an origin that’s centered while the enemy’s is in the top, left.

That means the enemy is within those values here

It would probably be more accurate if they both had the same origin point and then variance above and below was smaller. Also, the point used as the comparison point on the plant should be where the bullet fires from. That’s the main point.

An alternative would be to cast a ray from the plany’s mouth. If it hits an enemy then fire.

Edit:
For context, I tested your firing or targeting line by adding the draggable behavior to the zombie. This allowed me to test the range. I also added a play sound event on a copy of the for each with your y test range. That gave me immediate feedback as to when the zombie was in that range.

I thought about using raycast for this, but I find it much more optimized to use position since there are no obstacles in the middle between the two objects. Did you add an event or action for this?

1 Like

Okay, I think that’s fixed just by changing the zombie’s origin! Thanks, I have even more problems, but I think I’d better not rent you out so much! XD

1 Like

You’re welcome. Let’s mark this as [solved] and future issues can be put out to the whole forum. I wish you well and I will help you in the future when I can.

1 Like