How do I check if an object is within a radius of another?

0 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • > You just need to find the closest non-hit enemy then.

    >

    > http://www.blackhornettechnologies.com/Construct3Stuff/Samples/DistanceBounce.zip

    I've tried around a bit now and it still somehow does not work.

    I've copyed your code, the only things that have been changed have been the instance variables to fit mine. Yet somehow something is wrong!

    I've tried deactivating the first code you sent me (like in your most recent code) I've tried putting some code over to the other, I've tried having both of them on, and I've tried everything in between, yet still it sometimes keeps targeting an enemy far away and other wonky stuff.

    It probably has something to do with the functions. I cannot add the function on shooting the weapon because of how I want the weapon to act. I may describe how I want the weapon to act very simply right now:

    I want it to shoot out fast projectiles quickly that go straight ahead (with the Bullet behaviour) and when they hit any enemy while any enemy is nearby it should then "bounce" or rather fly straight to said enemy. They will bounce a few times before destroyed.

    So by this description your code works quite well, and you've done a good job, but I do not see why it does not work for me.

    I'm so very sorry for bothering you so much, and I am extremely grateful for the amount of help you're putting into this, thank you very much.

    Do you have any other ideas to how this could work?

    I also forgot to add a picture of the code, so here it is prnt.sc/uowmq2

  • You need to get rid of the first code, it isn't what you want. Otherwise you'd have to post the project, as it isn't obvious what the problem is.

  • You need to get rid of the first code, it isn't what you want. Otherwise you'd have to post the project, as it isn't obvious what the problem is.

    I believe I said that I previously tried that, and when I did it would not "bounce" to other enemies, it sat on the same enemy that it hit.

    I will try to send you the game, just give me a moment

  • You need to get rid of the first code, it isn't what you want. Otherwise you'd have to post the project, as it isn't obvious what the problem is.

    Alright, here's the link. Sorry that it took so long mega.nz/file/urRhEKiY

    This is the game I've been working on for a while and there are some glitches there, so I'll guide you through so that you can get to what you want to test.

    Start the project either by starting it via Preview Project or start on Layout 2 or 3. If you started via Preview Project or on Layout 2 you need to go to Garage and by scrolling a bit down you'll see a weapon with a little lightning bolt on the top. This is the weapon "Shocker" which is the one you'll use. When equipped you can press the little button in the top right to start the game. You shoot the gun on the left cannon with your LMB, and the right cannon with the RMB. There's also a glitch where the weapons will unequip when restarting a round so if you die you should probably restart the whole project.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Copy:

    -> Enemies: Set LastShockerUID to ShockerProjectile.UID

    to the 'On collision' event also.

  • Copy:

    -> Enemies: Set LastShockerUID to ShockerProjectile.UID

    to the 'On collision' event also.

    It worked! Thank you so incredibly much for your help today! I'm extremely grateful!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)