Enemy & HUD Help!!

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi,

    I'm kinda new here, and i need help.

    I'm creating a top down shooter, and my enemies always seem to find me. How do i get them to spot me, only when I'm near them?!

    I've tried searching this forum, and I got some example files. They didn't help, 'cuz I'm running an older version of Construct. I tried installing the newer version, but my project didn't open up properly!!

    As for the HUD, how do I get it to scroll along with my character?!

    So, can someone please help me?!

    Thanks!!

  • Hud is very simple, here are short instructions:

    1st. Put the hud stuff on its own layer

    2nd. Open layer options (click on the layer and you see the options on the left side of the screen)

    from there find ScrollXrate and ScrollYrate and set both to 0 and you're done

    EDIT Sorry I meant scrollx rate and scrolly rate

  • For the distance, you can use the System object's distance between points expression in the math section.

    it's formatted thusly;

    distance(x1, y1, x2, y2)

    The x1 and y1 refer to the first object to compare and the x2 and y2 refer to the second object, so in the case, the enemy would probably be x1, y1 and the player would be x2, y2.

    The condition I would use is the 'Pick by comparison' under the enemy object's conditions list in the 'Pick' category. So it would look something like this:

    Pick by comparison

    Value 1: distance(enemy.X, enemy.Y, Player.X, Player.Y)

    Is lower or equal to

    Value 2: <insert distance in pixels you want the enemy to notice you>

    Then insert the follow/attack action that you're currently using.

    IF you're using a version of construct that does not have the system object's 'distance between points' function, simply use pythagora's theorem

    So replace distance(x1, y1, x2, y2) with: (it's a little more complicated)

    sqrt(((enemy.X - player.X) ^ 2) + ((enemy.Y - player.Y) ^ 2))

    ^^ This is actually simpler than it looks, in plain english it's:

    The square root of; the distance between the enemy and player's X coordinates squared plus the distance between the enemy and player's Y coordinates squared. High school maths ftw

    I hope this has been useful

  • Hi again,

    Um, nothing seemed to helped.

    I did what u said about the HUD, i put it on another layer on top of the normal layer, went to properties, and changed the Scroll X Rate and Scroll Y Rate to 0% and 0%, respectively. And now, I can't even see my HUD let alone it scroll along with my character.

    Then I tried the "Pick by Comparison", and put:

    Enemy.X, Enemy.Y, Player.X, Player.Y

    lower or equal

    (I tried a whole bunch of numbers ranging from 1 to 1000)

    and my Action was:

    Enemy: Move to Player(RTS mode)

    I also tried changing it from "lower or equal" to "greater or equal".

    And it either was the same wherein "Enemy" would start charging at me, or he would just stand there, no matter how close or far I got.

    Please help me!!

  • Are you sure you wrote value 1 in the pick by comparison as:

    distance(enemyName.X, enemyName.Y, playerName.X, playerName.Y)

    Don't forget to put the distance in front of the paranthesis around the x1, y1, x2, y2, also use lower or equal. Make sure you're using the names of the sprites you're using, not the names I've given, they're just examples, I'm sure you're doing it the right way anyway.

    I'll show you in a little .cap I made just then, works fine.

    http://dl.dropbox.com/u/1289341/MoveTo.cap

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh hey, that worked, I hadn't put "distance".

    Thnx alot.

    Now only to get my HUD working.

  • You DID put your HUD on the very top-most layer, right?

    It needs to be the very first layer in the layout, with the ScrollRateX/Y being 0.

  • Yup, its on the top most layer!! scroll rate x/y is 0%!! what im i doing wrong??

    also, when i copied my HUD to the new layer, something went wrong.

    "error in private variables! the selected object has 0 variables, but the selected instance has 1. please report this bug to scirra" its my health sprite. its gone. it doesn't take any damage too!!

    any idea what to do?! other than remaking the object?!

  • Make sure the HUD is near the top left, inside the outline that shows the window size.

    I dunno about the private variable error. I guess you can just restart Construct.

  • Um, its at the bottom right, but it is inside the layout border(window outline). I kept it at the bottom cuz my game starts from bottom, then proceeds upwards.

    Also, I'm creating a new health icon!! restarting Construct didn't help!!

    Please, someone, HELP ME!!

  • Theeeen I have no idea. Post a .cap?

  • um, how do i post my .cap?!

    EDIT:- http://rapidshare.com/files/454351637/your.cap

  • Again, you need to put the HUD in the window border, not the layout border. The position it's at now keeps it way off-screen. Scroll to the top of the layout, and put the HUD right above that line (around 527,432) and you'll see what I mean.

  • Um, its at the bottom right, but it is inside the layout border

    Pretty sure you have to have the hud in the top left regardless

  • Oh, Hey that helped!!

    Thanks alot you guys!!

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