#Im not really sure why you need this,
1 messages · Page 1 of 1 (latest)
❌ AVOID defining a struct unless the type has all of the following characteristics:
It logically represents a single value, similar to primitive types (int, double, etc.).
It has an instance size under 16 bytes.
It is immutable.
It will not have to be boxed frequently
Ah that didnt all paste under the quote, hard to see on mobile
Basically theres no reason to use a struct here. Itd contain a lot of data, and doesnt really represent a primitive value.
Hmm, here's what seems to be accurate for my usecase:
✅ immutable
✅ represents a singular value (in my case, it's a transformation across a single frame)
❌ size under 16 bytes
I still wouldnt call this a singular value. It's quite literally composed of 3 "primitives" which themselves are composed of 10 primitives in total
Do you have an example of a struct, composed of multiple primitives, which you might collectively consider "one primitive"? It seems that, definitionally, you can never consider a struct a representation of a single value
The structs you're already using, Vector3 and Quaternion represents singular values already.
A vector itself can logically be thought of as 1 thing. So can a quaternion
A vector AND quaternion cant really be said to be 1 thing
Its really not common to need structs. Most objects you'll make will be classes
Hmm, okay, I think I'm actually looking for Animation events: https://docs.unity3d.com/Manual/script-AnimationWindowEvent.html
https://www.youtube.com/watch?v=pBD-Nuqf3EY
I'm wanting my hitboxes to update according to the specified set of transformations on a given frame, and so I'll need to construct an AnimationEvent object that I can then supply to the Monobehavior, which will then apply the desired transforms
I'm still not sure what you're actually doing. It really just sounds like you want to use animations in general
Oh, sorry, I shared the context of what I'm working in another thread, but not this one: https://discord.com/channels/489222168727519232/1288182260968718358
hitbox editing example
Basically, I have a Hitbox object that goes through transform transitions on a per-frame basis, and I'm trying to improve the hitbox transform workflow, but existing solutions that I've come across don't work for me because:
- it seems to me that Unity's native Animation editing has a lot of unnecessary baggage for my usecase
- hitbox editors for existing fighting games don't generalize enough to the implementation of my game
I think Unity's animation workflow is meant for visual rendering, and isn't designed for discrete state transitions
I see, yea they information given to you in that thread seems good. Im not too sure about this kind of work myself