Enemy & HUD Help!!

For questions about using Classic.

Post » Fri Mar 25, 2011 7:16 am

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!! :P :D
B
4
G
1
Posts: 33
Reputation: 564

Post » Fri Mar 25, 2011 7:41 am

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
B
11
S
3
G
4
Posts: 622
Reputation: 3,186

Post » Fri Mar 25, 2011 8:11 am

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 :D
I hope this has been useful :)
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Fri Mar 25, 2011 10:27 am

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!! :(
B
4
G
1
Posts: 33
Reputation: 564

Post » Fri Mar 25, 2011 10:43 am

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.

[url:3jgxm7v8]http://dl.dropbox.com/u/1289341/MoveTo.cap[/url:3jgxm7v8]
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Fri Mar 25, 2011 10:49 am

Oh hey, that worked, I hadn't put "distance". :D
Thnx alot.

Now only to get my HUD working. :(
B
4
G
1
Posts: 33
Reputation: 564

Post » Fri Mar 25, 2011 2:14 pm

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.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Fri Mar 25, 2011 3:11 pm

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?!
B
4
G
1
Posts: 33
Reputation: 564

Post » Fri Mar 25, 2011 3:40 pm

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.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Fri Mar 25, 2011 3:51 pm

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!!
B
4
G
1
Posts: 33
Reputation: 564

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests