Heyo!
Just being cureous - is there a reliable way to remove collisions between some objects? I'm not very familliar with Unity, but the first thign I've tryed - Physics.IgnoreCollision(Collider, Collider, true);
But that didn't work out.
It looks like some entities in the world doesn't even have collider component in them. only in childs.
I was working with OnHammerHit, using hitentity as the target.
First attempt use to look like this:
Aaaand... didn't work out. As I sai above - some items doesn't have Collider at all. Workbench, for example.Code:void OnHammerHit(BasePlayer player, HitInfo info) { if(info.HitEntity == null) { PrintWarning("No entity found"); return; } var playercol = player.GetComponent<Collider>(); if(playercol == null) { PrintWarning("Player dosn't have collider!"); return; } var entitycol= info.HitEntity.GetComponent<Collider>(); if(playercol == null) { PrintWarning("Entitydosn't have collider!"); return; } Physics.IgnoreCollision(playercol, entitycol, true); PrintWarning("Done!"); }
But even if the item has collider - that does nothing. So in my mind if I hit a chair with hammer - I'm able to walk thro it. But nope - i can't.
Another idea was almost the same, but getting all collider in child of entity:
Still doesn't work. Even setting entity colliders IsTrigger to true does absolutly nothing....Code:void OnHammerHit(BasePlayer player, HitInfo info) { if(info.HitEntity == null) { PrintWarning("No entity found"); return; } var playercol = player.GetComponent<Collider>(); if(playercol == null) { PrintWarning("Player dosn't have collider!"); return; } var cols = info.HitEntity.GetComponentsInChildren<Collider>(); PrintWarning($"Entity has {cols.Count()} colliders: {string.Join("\n", cols.Select(p => p.name).ToArray())}"); foreach(var col in cols) { Physics.IgnoreCollision(col, playercol, true); } PrintWarning("Done!"); }
Any ideas would be really appriciated!
Removing collisions between objects?
Discussion in 'Rust Development' started by Vlad-00003, Oct 8, 2017.
-
I've played around with this same idea before - I concluded at the time that it isn't possible. From what I had seen, I determined that at least part of the collision handling is done on the client-side. You could possibly disable networking between the entities, thus "hiding" it from your client, but then you'd not be able to see whatever it is you're walking through... but this is theoretical - I haven't tested it at all...
-
Most things use RigidBodies, maybe try playing around with those instead.
-
Try doing something like this to get the collider, seems to work (at least on some things?) for me:
Code:entity.transform.GetComponentInChildrenIncludeDisabled<Collider>()
-
Thanks for all your replies. Gonna try both - from rigitbodies and _collider (No, really, there is a var for this? didn't notice) and let you guys know.
@ignignokt84, I think you are right, but there must be a way to send the info to the client..... I'll post here if I'll find the solution.
[DOUBLEPOST=1507542095][/DOUBLEPOST] -
So far - this way of getting collider seems to be working:
Code:Collider entitycol = null; if(entity is BaseCombatEntity) { PrintWarning("First way"); entitycol = ((BaseCombatEntity)entity)._collider; } if(entitycol == null) { PrintWarning("Second way"); entitycol = entity.transform.GetComponentInChildrenIncludeDisabled<Collider>(); }
Code:Physics.IgnoreCollision(playercol, entitycol, true); player.SendNetworkUpdateImmediate(); entity.SendNetworkUpdateImmediate();
-
Sup? No one has an idea?
I'm gonna look thro the client assembly, maybe I'll found something there. Will post here if there would be anything usefull. -
Did you find a solution?
I have the same problem. -
Still nothing. No idea how this can be realized. Looks like the info about removing collision is not being send to the player, and I'm out of ideas right now. ALso don't have enought time, so...
Not yet =( -