Author Topic: Distance Check  (Read 1032 times)

Wizard Indie Games

  • Level 7: Tilbub
  • *
  • Posts: 145
    • View Profile
Distance Check
« on: July 03, 2020, 09:33:26 AM »
Is it possible to check the distance between the player and an enemy?  I want the enemy to detonate himself when he is close enough to the player.
Developer of:

AI Anomaly
Dickie A Cumming
Someone Cloned The President
Freedom! Do or Die
Pension Day
Red Mist: Rivers of Blood

Available on Steam

TingThing

  • Admin and Developer
  • Level 20: Nobom
  • *
  • Posts: 1395
  • Creator and Developer of Platform Builder
    • View Profile
    • Platform Builder Home
Re: Distance Check
« Reply #1 on: July 05, 2020, 11:44:24 PM »
Yeah, that's possible.


In the character settings, set death to detonate. And then in the looping command prompt, put this:


Code: [Select]
if distance to character 1 < 50
kill enemy


Change "1" to the character ID for your main character.
Change "50" to your desired distance.


I just noticed that "if distance to" is not in the list of conditionals on the website. I'll fix that...
« Last Edit: July 05, 2020, 11:46:43 PM by TingThing »

Wizard Indie Games

  • Level 7: Tilbub
  • *
  • Posts: 145
    • View Profile
Re: Distance Check
« Reply #2 on: July 06, 2020, 08:01:36 AM »
Cool. Thanks very much!
Developer of:

AI Anomaly
Dickie A Cumming
Someone Cloned The President
Freedom! Do or Die
Pension Day
Red Mist: Rivers of Blood

Available on Steam