When no physics is in use?
I raycast on click. Set the physics2D mode to script because I don’t use physics.
How come my profiler spends 10ms on physics when I am not raycasting? 5ms after setting mode to script.
thoughts?
When no physics is in use?
I raycast on click. Set the physics2D mode to script because I don’t use physics.
How come my profiler spends 10ms on physics when I am not raycasting? 5ms after setting mode to script.
thoughts?
Oh is it the presence of colliders ? Hmm
oh I can get click location without colliders so I’ll check it out if it has a near complete reduction
Yes confirmed removing box colliders reduced all physics and physics to less than 5ms but there are still spikes here and there
The remaining comes from Gameobject deactivate which uses physics.
however removing the editor overhead makes such degree of optimisation pointless. Lots of set active true and false hurts that physics. But also saves my rendering. And also prevents me from getting component of multiple objects. So I don’t really know if it’s worth continuing to explore its complete reduction
You really need to explain better what you mean, I’ve read it a bunch of times and I don’t understand. You seem to be using the word “physics” to mean simulation but physics is everything you use in physics: queries, joints, colliders, bodies, effectors, simulation etc.
No idea, you don’t actually state what its saying. “Physics” isn’t a thing, it’s a word. The profiler tells you exactly what it is doing.
Again, “physics”. What do you mean by this?
What do you mean here? GameObject deactive doesn’t “use physics”. If you deactivate GameObjects that have Physics components then they spend time doing that yes just like all components do. Maybe you mean something else?
Well yes, activate and deactivate are not just a single bool flag. For Physics components, the underlying physics stuff has to be destroyed and recreated if you reactivate. This is why Rigidbody2D.simulated exists to temporarily take it out of the simulation without destroying everything.
But also, you have to be doing a lot of these for it to take 10ms but then again these would happen when you deactivate/activate and have nothing to do with the simulation mode so confused again.
Whatever the reason, your post sound like thoughts and not descriptions that are asking questions which is what makes it confusing.
So gameobject deactivate causes physics orange to spike. When you select the spiked which in the above photo isn’t so bad. It highlights the physics orange and shows me that activating and deactivating a gameobject is considered physics
I thought I explain it clearly: anyways it’s not important
The spike I was concerned with comes from Physics2D.DestroyShapes
It shows this particular shape adds 2.24ms
As far as I am aware everything that gets activated and deactivated is the same scale and shape. There are no colliders or rigidbodies. Unless i guess it might have something to do with an old camera deactivating. I’ll have to check
No, that comes from a Collider2D being destroyed. As simple as that. Colliders are nothing to do with camera or deactivation on its own. A GameObject being deactivate will inform all components on it and children about deactivation.
That is from a GameObject with a Collider2D. It’s the only place that is reported.
You’re wrong no collider is destroyed no colliders on any object. I use nearest mouse position in vector int to locate objects who exist in a list of lists containing coordinates that correspond to mouse vector.
no colliders be destroyed or created.
Not destroyed, I mean deactivated as I said before. Shapes being destroyed because of it.
btw, by not being clear, I meant things like this. Honestly, this isn’t anything I understand.
I’ll check the hierarchy for colliders again but I am 99% sure no object has one.
What I mean is -
So the Vector2 Int of my mouse position is always a whole number.
my grid tiles exists at size scale 1x1, 32 pixels x 32 pixels per tile. And they are spaced from vector int 0,0,0 to vector int x,y, 0.
so as this is the case —- the int of the mouse position if it is greater than 0 and less than size.x will always be the same location as an existent tile.
so ; the tiles of this grid go into a list of lists. That points to the hierarchy where each tile has its child number as it’s name, and so the list of list points to this child number when asking List[×][y] so thus I can identify my object by child number from mouse position and I do not require colliders.
But I will go and check again and post update when I confirm that there is 100% no collider present that happens to be deactivating and activating in a rhythm
yo you were right it was caused by one box collider 2D who was attached to one of the parent objects. Now my physics is down to less than 1ms l. In fact it averages 0.07ms
As a side note, overall Collider2D shape recreation or shape destruction performance has been improved here.