Hello everyone! I’m having trouble making the attack blocks spawn at other players like they do with buildings. Any tips?
Thanks in advance!
Man, I cannot figure this out lol. I’ve been at it all day in between adding other systems.
I gotcha:
In the screenshot, you are checking if a player object is owned by a player (which is good), but then when you check if one is not owned by another player, it is checking that same one that it just checked was. Therefore it will always be false.
To fix this, you will need to create a sub-event that repeats for all players and, if not owned, spawns target block objects. The main issue is it is checking conditions for the same exact player.
Another issue is that the system will not work with checking if it is the same main object.
Basically, there are many issues that would stop the normal code. Long story short, here is what you need:
Also, it is important to note that under the Collision condition the Ignore objects that are touching on their edges is set to True. Otherwise this won’t work.
If there are any issues with this code, reply to me and tell me so. I will try and find another solution that involves multiple Player objects and is very messy (I tried to avoid this one at all costs, you don’t want the work lol).
You don’t understand HOW grateful I am. I’ll test it out immediately to see if it works! Thank you so much!!!
Um, it doesn’t seem to work unfortunately. I’ll keep looking through it.
I think I vaguely see what the issue is.
In the second block, it checks if the player is not owned by us, then because local variables are not synced, it checks if our player’s position within (24) pixels of itself, and it then create the block at itself and proceeds to destroy it.
Wait no, it’s not creating a block anywhere actually, because it’s checking if the X position of the player is less than (24). A block will only be created if the player is at X 23 or less.
Oh yeah, and the sub event is checking if the same player object as in the first one, so it’s always going to return false.
Let me know if you want another code block and tell me what you want in it
I don’t understand the purpose of these events:
because:
@cattymations, I think this is what you’re after:
The first event gets the current player’s position
The first subevent filters to all player objects not owned by the current player and within range
The second subevent iterates over all the valid player objects (those owned by other players and within range), creating a TargetBlock on each.
Actual game changer man. I was overthinking it so much by trying to make a whole state machine lol. You’ll be going right in the credits.
I’ve found that when there’s more than two players or buildings, it ends up creating a block at all of them regardless of how close they are. I think I’ve almost got a solution down, but just wanted your two-cents in case I end up getting horribly stuck again lol.