Hey, you! Let’s Battle! (Or at least switch game layouts.)

5
Official Construct Team Post
Laura_D's avatar
Laura_D
  • 30 Aug, 2019
  • 505 words
  • ~2-3 mins
  • 1,042 visits
  • 1 favourites

It’s Friday, which on its own is a good thing, but when you’ve also finished another test project for a game mechanic (that actually works) it’s even better!

On Tuesday, I finished working on a very basic version of what I call the ‘Let’s battle’ mechanic. You know when you’re in a Pokemon game, and you walk in front of an NPC and they spot you? Yeah, that. Currently it uses placeholder events just to prove the concept, but eventually, I should be able to plug the battle system in there and NPCs will be able to challenge you all on their own!

It took a little bit of work to get this right – originally, I thought I could use standard Line of Sight behaviour, and just rotate the NPC’s base as it faced a different direction. However, I completely forgot that the origin point of the base is not in the centre, so any rotations would shift their grid position. Not helpful!

Then, thanks to a tip from Nepeo, my focus shifted to the Raycasting actions within the Line of Sight behavior. Now, depending on the direction variable assigned to the NPC, they’ll cast a ray in a specific direction. So, we can have Line of Sight active in any direction without having to think about moving the NPC components! Excellent.

Now, whenever the player walks in front of one of these NPCs, they spawn a little exclamation mark, then walk towards the player. Then the layout switches to a dummy one, with a button to go back. We return to the original layout and all is fine and dandy.

Until you realise you’re stuck in an endless loop of layout switching.

BOOLEANS TO THE RESCUE!

Each NPC now has a Boolean variable that dictates whether or not it ‘CanBattle’. So, not only does this mean that not every rando in every city will want to battle you (thank goodness, that would be a lot of teams to come up with) but it also means we can disable the ‘CanBattle’ state upon entering the challenge sequence. No more endless loop of layout switching and no more Joey throwing his top-percentage Rattata at you for the fifty millionth time. (NO ONE CARES JOEY.)

So yeah. I’m happy this all now works, and it’s a different system to the talking interactions I put in before and both function independently. Hurrah! That means I’ll probably create a tutorial for it at some point – perhaps in a course with the NPC movement one I’m scribbling at the moment. We’ll see.

And as a final note, I did a thing yesterday and I think it doesn’t look half bad. Introducing the Inott Department Store!

OH. And final, final thing. Please put any suggestions for Construct games you want me to play in the suggestions box on Twitch – I want to put a poll out next week to decide what I play next! Do we carry on with Healer's Quest, or do we play something new?

Subscribe

Get emailed when there are new posts!

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!