Help with nearest obj

Discussion and feedback on Construct 2

Post » Fri Aug 18, 2017 8:13 pm

yeah tried those, the bullet just goes to the 1st hitbox
https://www.dropbox.com/s/9mty0n1b2sx1cvr/RPG.capx?dl=0
I'm not sure what I'm doing wrong
B
5
S
1
Posts: 11
Reputation: 347

Post » Fri Aug 18, 2017 9:33 pm

dwtiger wrote:yeah tried those, the bullet just goes to the 1st hitbox
https://www.dropbox.com/s/9mty0n1b2sx1cvr/RPG.capx?dl=0
I'm not sure what I'm doing wrong


Event 12
On the Action, you didn't choose the Family you choose the object of that family,
you moved the sprite10 towards the (Hitbox = Object) is wrong you should move the sprite towards the (Family = Hitboxes)

just replace (Hitbox.X, Hitbox.Y)

by (Hitboxes.X , Hitboxes.Y)
B
38
S
22
G
61
Posts: 224
Reputation: 34,536

Post » Fri Aug 18, 2017 9:44 pm

Thank you so much! Hopefully I'll be on a clear path to finishing this game... Eventually. I don't think I could've fixed this on my own!
B
5
S
1
Posts: 11
Reputation: 347

Post » Fri Aug 18, 2017 10:23 pm

dwtiger wrote:Thank you so much! Hopefully I'll be on a clear path to finishing this game... Eventually. I don't think I could've fixed this on my own!



Yw sir,

cool that you are back on track
Good luck with your game, you doing really well man keep going, One thing I will do before you go further with your project and it gets much bigger and messy you will have a hard time to find bugs, so I recommend you to stop for a few hours just to organize your code in groups before is too late, and look for things where you can optimize them
example:

Why use an enemy size of 280x280 when his actual size is just 36x36 ?? you are wasting x8 times more memory for each enemy when you could just put 36x36 and use the Line of sight to see if the enemies are in the range of the Player like you do with the overlap but cheaper. you will save memory and collisions checks

Read this very carefully:
https://www.scirra.com/blog/112/remember-not-to-waste-your-memory



Another thing remember to keep testing performance to see if you are doing something wrong that can hurt you performance

Create a layer call it "HUD" then click on that layer and in the left panel look for parallax change the (100,100) to (0,0)

Now create a text in that layer HUD

And on the event sheet add

Every Thick: >>Txt >>set txt >>to >> "Fps: " & fps & newline & "Cpu: " & round(cpuutilisation * 100)

so with this, you will see the fps and cpu on the screen all the time while you testing


And here is a link for some info about Groups:
https://www.scirra.com/manual/80/groups
B
38
S
22
G
61
Posts: 224
Reputation: 34,536

Post » Tue Aug 22, 2017 7:23 pm

Hi @dwtiger

I had some time free and I thought to give you a hand so I organized your capx and modified it a little bit, I touched only "Event sheet1"
The purpose is to help you understand how to Link and Pick objects, and to better plan and optimize your events using different behaviors instead of overlaps and that will help you also in saving some Memory as you will not need to use to those big images for your enemies etc......

Important Notes:

Containers:
In this Example, I use "Containers" because it's much easier to link objects with his parents or saying it differently we use less that Variable "BelongsTo"
Here is the link to the Manual to understand more about Containers
https://www.scirra.com/manual/150/containers

Waits:
"Waits" Are replaced with "Timers" Thanks to @99Instances2Go Tutorials and Help and warnings as they can cause many problems for the lack of desynchronization a simple Example: if we wanna fire up bullets every 0.2 seconds, doing it with waits it can end up in some points firing up two bullets at the same time and we don't want that
Timers Link: https://www.scirra.com/manual/167/timer

Functions:
And Last I used "Functions" to better organize the events and because you can scale it up easier by adding more enemies so you will just need to modify The "Functions" and add the new Enemy to the "Family Enemies" and if this new enemy does have different Abilities or fire rate etc... just change his variable "Im_The" to what ever name you want so you will have it much easier to identify when you pick through the Functions so you can apply different abilities
Manual: https://www.scirra.com/manual/149/function

Some Useful Links:
https://www.scirra.com/manual/142/families
https://www.scirra.com/manual/75/how-events-work

Heyy is not the best job but the purpose was more to have an overview of how everything that I mention above works, let me know if you have any questions, the capx I left it with no comments on purpose so you can study it to see how everything is linked together is the best way to learn, I hoppe it helps you


Capx: https://www.dropbox.com/s/2uplqmxse9ky4mf/WithContainers1.ver-r244.capx?dl=0
B
38
S
22
G
61
Posts: 224
Reputation: 34,536

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: ugurtufekci and 5 guests