Hello. I have a simple event to make the player face who he is talking to, but I am sure there must be a cleaner way of doing this than pasting the same events for each NPC. The only difference between each block is a variable check. Each NPC is a separate object - not separate animations within one object. This is unavoidable because NPCs may vary in size and have various animations each.
My question: how do I make a single event that will flip my character for any NPC he talks to?
I tried grouping them to see how that would behave. The player would flip when in collision with either NPC in the group, but he was only using the X position of the first NPC.
I think the answer will help me way beyond this small problem. Iām getting on well with GDevelop, but more dynamic stuff is a little out of reach and that means my events are repetitive and verbose. They work, but I know they could be better. Thank you.
Hi!
According to the limited knowledge I have about that, I would at the beginning of the game, in the scene editor, give each NPC an object variable ānameā that record their own name.
In scene editor I would also group all NPCs in a group called NPC.
Then for checking if frodo is on right or left that the NPC heās talking with, Iād do like that :
That means the event will try each instance of objects in the group NPC. For each of them it will check if thatās the one frodo is talking to.
(if you have several instances of a same NPC object, maybe youāll need to add a condition like ādistance between frodo and NPC< somethingā , so only the instance heās talking to would work)
Please someone who know better confirm itās the best way to do itā¦!?
I think thereās no other way to dynamically access an object (I donāt really know why).
Thanks Bluzima for your time, but that doesnāt seem to work for me. The player faces the correct way for the first npc (trevor), but it breaks for brenda: none of the actions for that event work when I talk to her.
I havenāt used ārepeat for each instance beforeā. That did it!
Thank you @Bluzima for going to the trouble of creating the events and solving my problem - Iām sorry I didnāt realise it right away! Thanks also @MrMen and @beanmatt for nudging me along.