I’m having trouble again, and I didn’t want to ask for help again, but I’m just stuck and can’t find anything to do. the damage system I used has a problem because I can’t figure out how to make it repeat itself. The limitation is that whenever it attacks something, it needs the signal sent by the area, and it cannot be repeated because it only calls the signal when something enters the area. Is there a way I can make it repeatable to add an attack cooldown, or should I just give up and make the dinosaurs shoot projectiles at this point? I’ve already tried those basic things and can’t get them to work. if cooldown is true, then call the function or something else, and it just doesn’t work.
didnt mention you i think oops
Hi, I see what you mean, when you wrote your code, I saw it right away, but I didn’t mention it anymore.
I solved it like this:
You create a timer for the attack interval and set the settings:
Oneshot = true
WaitTime = “your time in seconds”.
Autostart = false
Don’t forget to add a timer via AddChild(timer)
Then you do a check during the physics.
if (attackComponent.has_overlapping_bodies() and timer.IsStopped()):
attackComponent.emit_signal("Attack")
timer.start()
The logic is as follows, if there is an intersection with the player’s area (you should set the dinosaur to have the attack area collide only with the player’s hitbox area, then you don’t have to check who is in the area) and the timer is stopped, i.e. the attack interval has passed, then send a signal to attack. That’s it
about the optimization of this case, personally I do the project bullethell and when it comes to 300 enemies, then only then lags begin. so if you will have on the location <100 dinosaurs, there should be no problems.
Okay, so I spent an hour trying this, and it didn’t work. I messed with a lot of things, like changing the signal, the code, where the code was, and the stuff it sends. I then changed some of the timer stuff and the area stuff, but again, nothing worked. I tried something similar to this before, and the problem is kind of the same. Whenever you emit the signal, you only emit it with its name. It says:
E 0:00:08:0541 AttackComponent.gd:11 @ _physics_process(): Error calling from signal ‘Attack’ to callable: ‘Area2D(AttackComponent.gd)::OnAttack’: Method expected 1 argument, but called with 0.
its basically telling me that it won’t work because if you want to emit the signal, then you need to emit it in the area. I can’t really get that area, and its required because when it emits the “attack” signal, it emits the area with it. I tried making it so that it would do the hit signal instead, and then it just wouldn’t get the area, so it would emit the hit signal to nothing. Yeah, I could try more stuff, but I’m just making meaningless guesses at this point. to wrap it up, it just won’t emit the attack signal because it wants you to emit the signal with its area. i also moved the physics process to the character body movement sequence, and nothing changed
heres a picture of the code
I changed the code so much and it lost its original stuff, so that could have something to do with it, but I don’t think so because for this entire combat system, the root of all problems has been the same thing. method expected 1 arguments but called with 0
any solution you can think of?
I made a test project with 4 components and 2 managers. I transferred scripts from my other project on github, all scripts there are in C#, but if you want you can see how I created components for my needs
Using this project, try to draw everything on paper, all the logic you will understand to see how they work together.
The basic logic I can say this:
HealthComponent.self - Solo
MovementComponent.self - Solo
(1) AttackComponent.not_self → HitboxComponent.self → HealthComponent.self
(2) AttackComponent.self → HitboxComponent.not_self → HealthComponent.not_self
Wow thanks alot.
I went through the project and i understand it. I think the problem for my old code was just that the on_area_entered() function. That was kinda a useless function but it was required to be called in order to attack. I spent some time changing the code and i manged to make it work on my experimental version. Ill implement it to the main game and implement death and stuff but i think everything should work right.
After going to the main version all i did was make the attack function a normal function instead of it being called by the signal and then i removed the number stuff for the function and i worked perfectly fine. I made it so instead on area entered the timer starts and its not perfect but i understand the problem. I think i was just confused because when you intially told me how to make the attack system i thought i had to make something emit a signal to give the attack a area to attack but the attack function can get the attack area itself and its working now on the main and test version so ill polish it and add all the features when i get out of school. Thanks alot for your help. Ill probably need help again but using the github stuff made me realize what i did wrong and i appreciate the time you spent helping me out. I was running a Tiktok about like the devlog and i got a few thousand fews and it was cool and stuff but i just gave up after i spent 10+ days failing to add combat so im glad i finally got it working consistently for now and i might start uploading again. Thanks alot
This is cool, by the way this project I was also doing for release in tiktok, but I haven’t gotten around to it yet :0
I think you should start uploading some dev logs or something, because its good to just start as early as possible. You’ll have to learn a lot, so uploading a few videos is good even if you’re not ready because you need to learn how to make good videos. I haven’t had too much success, but I’ve been on and off trying to do social media stuff, and I found some success getting an account to 1200 followers and 150k likes, but the first videos weren’t very good, and I learned a lot from previous accounts and stuff, so its best to just start as soon as possible. good luck with your project. If you ever start an account, I would be glad to support it.