Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 1 of 2 |
|
|||||
|
Alright, because my previous thread name isn't about the current state of script, I'll try to write here. So, first of all, it appears that the turret won't unregister the shoot function after player's death and the scene reset. Which means that after I got killed by turret and restarted level, it will stand still without rotation, but it will rapidly shoot. Also, as you can see, it shoots incredibly fast. But the thing is that the AttackCD (cooldown) is on 2000, but for some reason firerate got attached to FPS. I don't know how, but this did happened, yet I am trying to fix this. So, is there a solution to unregister the function after player died? |
||||
|
To disable the turret when restarting the scene - 1- you can use a simple variable to disable the turret (eg: If Active? = 1, then do......" or 2- you can use "on proximity" to make the turret active when you're near it and inactive when you leave it's range. As for the bug you mentioned - did you use the "Do Later" script in "Before first Draw" at all? |
||||
|
Well, I have a DoLater on a start. Two of them. It goes like "Before first draw", "If a variable has a value do something" and there "Do something later". It's just for sure. |
||||
|
OK, so I think that's the problem. The "Do Something Later" Script causes lots of bugs when placed in the "on first draw". If you check out some of my posts on the [bugs] section, you'll find the solution - someone uploaded a new script/plugin which works perfectly. If I find it, I'll post here, if not, you can find it by searching the posts - the post wasn't too long ago... |
||||
|
Here's the post I mentioned. Sorry to say it wasn't the "do something later" script, it was the "Animate Scale" script that caused problems when the "Do something Later" script was used in the "Before First Draw". Either way, it was fixed by editing the script..... https://www.ambiera.com/forum.ph... Hope this is helpful for you. |
||||
|
Well... I don't use the "Animate Scale" script, so, I suppose this won't help me much. Also, maybe I did something wrong, but your solution about shooting after scene reset didn't really worked. Also, trying to make this, I broke the stopping of shooting somehow. So, I'll leave the code here: /* |
||||
|
As mentioned before, I simply used the "turn towards" action and selected a target node for the turret to point to. This method definitely works for me without problems but I understand that you want to code it for yourself - I've no idea how to script though, so I can't check your code for you. Having the "do something later" or the "animate scale" in "before first draw" definitely caused multiple problems for me on several projects (until I swapped out the "do something later" and "animate scale" scripts for alternatives suggested in the post I linked). If you're convinced that's not the issue - other than uploading a ccb with a working example of my turret for you, I can't suggest anything more - so hopefully someone can fix your script for you instead. Good luck - hope it gets fixed. |
||||
|
Well, guess I should do this with a wacky-clanky way, because the "DoLater" isn't the reason: I tested my script in clear project and nah, it didn't work well. So, I will do it in other ways. Anyway, thanks for trying to help, VP. Hope I'll get better at the JavaScript... |
||||
|
I have made simple Turret script .. Download CCB. https://drive.google.com/file/d/... There you can edit GUN magazin size..its firerate..its reload time (that you can use as cooldown counter also) My script should be easy to understand and easy to modify as you need. //Made By User sven at Ambiera Forum (2021 year) |
||||
|
Believe it or not, I found the reason of this mess. And guess where it was? In almost the begining of script! if (Col == null && dist <= this.DetectionRadius) So, the reason was the fact that the script every frame player was in detection radius made variable can_shoot get the yes condition... Should I say more? (Yeah, I should. I didn't saw this for a week or something, which means that I should've do a better code structure in order to see the stuff, because there is a lot of text so close to eachother). And, well, this means that it's not over yet - I will try to make this thing working... "Huh" and "eh" until it's "Bruh". |
||||
|
I know this thread is old but I can't say thankyou enough for this |
||||
|
I don't know how someone was even able to find this old thread, but damn, looking at the script I made there... Damn. This "can_shoot" part is especially horrible, since it's not boolean true or false but rather string "yes" or "no". I mean, I was only starting to learn programming back then, but this is probably bad even for a starter. |
||||
|
I can feel that I remember the first behavior I wrote "CheatSheet", now when I look at that behavior, I think man how bad I was, but then suddenly I start thinking in reverse, no man you weren't bad, you just improved your skills. I can now create way better scripts than those. I think at some point I will update those obsolete extensions and video tutorials on my website that I created years ago. I am thinking of creating a series of tutorials for Coppercube after my exams, at least one video every weekend. |
||||
|
I would love it if you did that I'm not very good at scripting with coppercube and need help |
||||
|
@spicymilk, there are already actions available on the neophyte.cf that you can use to create a sentry gun(turret), all you need is to use the action together with a shoot action. here is the link to the actions that rotates and object toward another object https://neophyte.cf/ccb_action_r... |
[ 1 2 ] Page 1 of 2 |
|