Hi,
I would like to know if there is a way to detect objects such as boxes, sleeping bags and so on ... when I have the foundation (or any BuildingBlock) it is on.
I can get all BuildingBlocks of a building but I can't find what is on each of them.
what I tried :
-> For each BuildingBlock, call Physics.SphereCast towards up but it didn't hit anything
Solved Getting object above foundation?
Discussion in 'Rust Development' started by mangiang, May 16, 2017.
-
Adapted from what Facepunch does to destroy deployed items if the building block gets destroyed:
Code:BuildingBlock block; // your BuildingBlock Collider component = block.GetComponentInChildren<Collider>(); if (component) { Bounds bound = component.bounds; List<BaseEntity> list = Facepunch.Pool.GetList<BaseEntity>(); Vis.Entities<BaseEntity>(bound.center, bound.extents.magnitude + 1f, list, 2097408, QueryTriggerInteraction.Collide); foreach (BaseEntity baseEntity in list) { if (!baseEntity.IsDestroyed && !baseEntity.isClient && !(baseEntity is BuildingBlock)) { // DO STUFF } } Facepunch.Pool.FreeList<BaseEntity>(ref list); }
-
Thank you, it works very well