#Scripts added twice (Editor bug)
1 messages · Page 1 of 1 (latest)
D:
That screenshot
Two Components of the same kind on the same object
that's a huge error
only happens with scripts so far
oh wait
it is possible xD
but for it to happen at the same time, is obviously a bug
so it's not a problem with my project?
Can you safely Save and Exit the project right now?
Alright. Do that.
Then navigate to the project folder, and delete the folder named Library
alright
There is a lot else that can also be deleted, but try it with just that first.
The Library folder will be regenerated upon project start.
Alright. And you don't have a line with AddComponent in your script?
happens with every script
Exit the project again. Delete the Library folder.
Next, make a compressed archive to backup your project, before we proceed.
What type of project is it so far?
Is it a game, or an Editor Script project?
it has both
How many days or weeks work is in this project?
like a month or two
Alright. With a backup, we can safely delete stuff here and there.
it would suck to lose the progress :P
With a backup you are entirely safe. You can even copy the entire project folder to another drive or whatnot.
With that much work, you need to be certain.
making a zip of the folder rn
I'll explain some about project composition.
it's just a shoddy space invaders clone so nothing valuable but it's my 2nd overall game project
The factors which make Unity recognize this folder as a Project, is that is contains the folders:
Assets, Packages, and ProjectSettings
And that there is a valid ProjectVersion.txt inside ProjectSettings.
UserSettings is also a keeper, but can technically be discarded, as Unity would generate a default.
When you have 2 backups, you can delete the following:
2 backups?
One for each month's work ^^
oh
hah
I only have a backup of the current stuff, no in between ones
but it's all on github
oh yes I forgot to ask if you were using Version Control.
Is your project fully backed up there?
I have some changes that aren't committed but otherwise yeah
Alright.
I would make two backups.
of the same files?
Balanced
alright I zipped my project folder twice
Folders to delete:
Library
Logs
obj
Temp
Files to delete:
All files directly inside project root, except .vsconfig (I really doubt that's the culprit)
Though you could
I don't have temp folder
That's fine
yes, and keep .gitignore (Unity won't regenerate that)
done
Now, you can start the project up again, wait for an eternity, and see if it still adds the script twice.
might take two eternities 👴
If this doesn't fix it, then I am at a loss for what to do next.
If it's project-breaking, you need to move the question to #💻┃unity-talk
yeah I've never experienced that
Ah one thing - if you're not using a project root namespace, then one of your classes could be causing a conflict, but I believe Unity would message that in a warning.
conflict due to identical name
is it true for only scripts, or all components?
Is it different if you add it via Add Component in the UI, rather than drag-and-drop?
Steps to reproduce: 1. Create a new Project 2. Create a new Script in the Project Window 3. Create Cube GameObject in the Hierarchy ...
Screenshot your Unity Version in the title bar
Did you upgrade the project to the latest Editor version?
yes
I see. They have introduced the error at some point.
but the problem didn't start happening immediately
You should log in and post about your experience, so that they realize it also affects 2021 LTS
will do
Or perhaps create a new ticket. I will ask a mod.
if I can finish this last crucial functionality for my game
If you're close to finish, that's great!
Very good. This might not be a big issue for you then.
it's mostly just a nuisance
I give no guarantees, but if I can spare some time I might come up with a scriptable solution to remove duplicate scripts
I could just start adding scrips from add component instead of dragging it
the workarounds given on that link work
Which part is that?
You know space invaders, it has those shields/barriers that take progressive damage depending on where they were hit
How do you want it to work?
I can't recall if I've played that specific game actually
unless you were in the arcades back then or emulated it somehow I'm not surprised
but the way I was going to solve it was split the barrier sprite into many smaller ones, then try and piece them all together in the editor to look like the full barrier again
and each little piece gets a collider so only certain parts get destroyed
Ah you want the shield to be based of separate components, which can fail
that's the only approach that makes sense to me
is this 2D or 3D?
2d
How does it look?
the barrier?
yeah
this is the script I made
not script
sprite
here's how it looked in the original game
you can see how the barrier gets destroyed progressively
So there's a forward barrier which progressively deteriorates
yeah but the player can also shoot it
kind of like the steel bricks in Death Race
the player can damage the barrier?
hmm
I would ask in #🖼️┃2d-tools or #💻┃unity-talk.
I haven't made anything like that, and others probably have better ideas.
I try not to make other people solve my problems too much, if I can't implement it well I def will ask
I have one idea
The barrier could be split into objects which can be removed
Add decals from weapon fire.
When the barrier is hit, it will register whether it came from North, East, South, or West. (but in vector logic)
By using the direction of the surface hit (surface normal).
Based on which side it was hit from, remove barrier objects from that direction.
A bit crude. I'm sure someone has a better one 😅
yeah somewhat what I was gonna do
but since the sprite has to degrade progressively, the collider also has to change
When one of the 4 health pools is depleted, the damage has to be redirected to one which is not.
With a health system, several shots are required to remove each object.
indeed
my project is somewhat extendable
you can look through it if you want I have it public on github!
As for the collider.
Use one collider for each object.
Set them to a layer named "Barrier" or something.
Make them not collide with one another (in the Collision Matrix)
And instead of having one health pool for each object, you can use the wonder of static
Are you familiar with how static works?
somewhat yeah
my object oriented knowledge is weak, my muscles were with functional programming
The script on each object should have a void OnCollisionEnter, which detects if it was hit, and from which direction.
You can use a Dictionary<Vector2,HealthPool> to match surface direction (normal) with the health pool for each direction.
And if the health of that particular pool is 0 is lower, choose another, based on whatever
Static is collective consciousness.
All the instances know about the statics
And there is only one of each static
So instead of the health pools being attached to the objects,
you will have 4 static HealthPools
Or for simplicity: floats that represent Health
private static float[] _healthPools;
private static Dictionary<Vector2, float> _poolDirections;
private static bool _initialized;
void Awake()
{
if (!_initialized)
{
_healthPools = new float[4];
_poolDirections = new();
_initialized = true;
}
}
wait yeah you're right!
D:
it matters if it was shot from below or above
yikes
this is even harder than I imagined
I mean
I have to do the sprite work for each section that can be destroyed
and for both directions it could be destroyed by
in case you're curious
private void OnCollisionEnter2D(Collision2D collision)
{
Vector2 direction = collision.GetContact(0).normal;
Debug.Log(direction);
}
Actually, there's a bug with OnCollisionExit's direction output
so I'll give you a copy of my basic physics based ground check.
https://gdl.space/erowolijux.cs Basic example
https://gdl.space/okafaqatap.cs All directions. Includes formula to calculate surface normal.
makes sense
the difficulty isn't as much the collision, more how I want to split up my sprite
and how I want do do the sprites themself
hm
no
I think I have to do it different
Alright
I think I have a sprite solution that doesn't depend on direction at all :D
Nice!
Feel free to link me when you're done with it.
I'd like to see how you solve that :)
It'll be a lot of sprite work
my initial idea didn't pan out exactly but your input of the health pool might give me some other idea
Scripts added twice (Editor bug)
@versed flame I got it working 90% how I want to
Good stuff.
What's left?
well, so far only the pixels that actually got collided with get destroyed
gotta work out a way to destroy some surrounding ones with a semi random feel
Alright.
What I was thinking is you can get a random direction from the point of origin to the point within the circle, thereby pointing outwards in a random direction.
makes sense
but it gets one random point only?
the destruction can't be too random though
Well yes, so if the direction doesn't lead anywhere, you'd just try again
like the immediate pixels next to the origin pixel should be destroyed
not a great solution
creating an impact zone
and then some outter ones that aren't immediately connected as well, these should be more random
Actually, if you want a random direction, it would be better to simply make 4-8 vectors inside an array, and get a random array element
it's not a random direction so to speak
I'll see if I can get my idea to work and if it does I'll let you know
can a circle collider even detect multiple hits at once
Actually, you'd be much better off asking for ideas in one of the other channels.
I do not have that much experience actually creating games. I have focused on coding in general and editor scripting.
if I can't figure out a working solution sure thing
hold on, I'm a lil confused
wait nvm
the thing is though, does it contain everything within the circle or just whatever gets hit on the circle outline
You can test that.
i hate how you have to write it yourself if you want to see the specific raycast
They are changing that in 2022 or 2023
cool news
I have a parent object with a script that I give a sprite to, the script reads the dimensions of the sprite and then loops through the sprite looking at each pixels alpha layer to decide whether or not to instantiate an object or not
calculate the position of the object and build a representation of the sprite with individual objects that all have their unique colliders
that's quite elegant
On collision the individual pixel performs 2 circle casts, a smaller one and a bigger one. the objects caught by the smaller one get destroyed immediately and the ones hit by the larger ones get destroyed based on a random range of 0 to 15, if it's larger than 15/2 it gets destroyed
now I have to finish some loose ends, handle a game over, make a starting screen, implement resetting my game without reloading my scene
etc
get my animations working, implement sounds
then it's finished
It will be there
Good stuff.
Remember to add comments, so you know what the code does in 2 weeks.
yeahh.......
xD
Perhaps you'd like to see an example
(I'm having trouble finding a good one xD)
This is my most fresh example of runtime code
https://gdl.space/dojabahuha.cpp
I made it readable with some Enums and descriptive method names, plus comments.
Not a great example, but it's something.
I am a chronic non commenter