# Duels with multiple sprites

0 favourites
• 5 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
• Hello everyone,

I galley for a moment to know how to solve my problem.

Description:

I have knights and monsters on the same line.

The knights move to the right and the monsters move to the left.

When they meet, they fight.

What I have today:

There are several monsters that fight several knights at the same time (superimposed sprites).

And the more time goes by, the more monsters and knights stack up in the same place, against each other.

What I would like to have:

When a knight meets a monster, he throws a "duel". The other knights or monsters who encounter this duel pass by and provoke another duel if he meets another entity.

When an entity wins its duel, it advances to meet another enemy and causes a new duel.

I do not know if it's really clear and sorry for my bad english.

• Hiya, gameplay like this is always a little tricky but you can take duelling objects out of the equation by using instance variables. You can say if a knight overlaps a monster, start a duel, this could be a function or just an event. You set an instance variable on the knight and monster to true (boolean), or to some value to show that it has been picked and is duelling i.e. changing a 0 to a 1.

Then you use the following logic in general, knight is overlapping monster and monster has not been picked (variable is not set) then start a duel. Therefore if the monster is picked then the knight will walk past it and look for another one.

I'll tell you if it worked

• Hi,

I tried that.

However, I still block.

I identified variable 1 as a duel and variable 0 (initial) out of combat.

Then I said:

- when overlapping between a knight and a monster, the variable goes to 1. I also indicate that the knight and the monster must be in state 0 for this event to occur.

- variable 1 activates, I say that the two entities must stop and attack.

It works in part.

However, the victors of the fights do not return the state 0 and therefore no longer move, it remains frozen.

I can not resume the loop, even indicating that in state 0 and each tick, it must resume movement.

Another small thing, the entities that participated in a duel, no longer participates in any other duel (as it did not return to state 0 to resume the loop).

I do not think it has to be complicated, but I tear my head off.