-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding back ZoneComponent #5123
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't speak for the playcanvas maintainers but from my perspective it meets my needs quite nicely and I've built a reflection probe volume implementation using this where mutliple reflection probes can be switched into as objects move into its zone. This includes zones within zones also
An early build but I've got authorization to share it |
Hey Mush, got some more feedback for you. I've recently enhanced my reflection probe work to now implement support for box projected cubemaps using the zones underneath (got a separate bug coming for those, rotation doesn't work ;) ). However I've found two issues
|
Hey, Thank you for your feedback! It was intentional to restrict the point check for the position of the entity and may you want to have a mesh away from the entity my suggestion would be to have the entity you look for at the position you want it to be. Having the possibility to work based on the mesh would however be interesting and it might be relevant to do the same as I did for collisions support, if that something you are interested into having a look please go ahead and contribute to the PR. Rationale behind the position being a point by default is that if you have a character at the surface of the water, half in water and half out you only want to be in the "underwater" zone if the point is underwater and not any point of the mesh and I think this precision is important to keep. Finally regarding the time to trigger events was initially set in the loop before the entity was added/removed which I changed few commits ago based on your feedback. I completely agree on this change and just pushed a new commit to reflect it! |
shapeCast
and mergedraycastFirst
andraycastAll
intoraycast
#5039 to be merged.Adding back the zone component. It supports detection against entities position as well as using colliders. Dectection from colliders can be disabled from
ZoneComponent#useCollisions
. Zones an entity is member of can be accessed throughEntity#zones
property, it is a getter to avoid circular references asZoneComponent
contain entities inentities
.Here are the full API changes:
Entity
zone
: Gets theZoneComponent
attached to this entity.zones
: List of all zones this entity is currently within.zoneEnter
: Fired when the entity enters a zone.zoneLeave
: Fired when the entity leaves a zone.ZoneComponent
shape
: The shape of this zone. Can be abox
or asphere
.halfExtents
: The half-extents of the box-shaped zone in the x, y and z axes. Defaults to [0.5, 0.5, 0.5].radius
: The radius of the sphere-shaped zone. Defaults to 0.5.useColliders
: Whether the zone should look for colliders collision if entity is outside of it. Defaults to false.entities
: The list of entities currently inside this zone.isPointInZone(point)
: Check if a point is within the zone.entityEnter
: Fired when an entity enters the zone.entityLeave
: Fired when an entity leaves the zone.ZoneComponentSystem
:zones
: Holds all the active zone components.ZoneComponentData
:shape
: The shape of this zone. Can be abox
or asphere
. Defaults tobox
.halfExtents
: The half-extents of the box-shaped zone in the x, y and z axes. Defaults to [0.5, 0.5, 0.5].radius
: The radius of the sphere-shaped zone. Defaults to 0.5.useColliders
: Whether the zone should look for colliders collision if entity is outside of it. Defaults to false.CollisionComponent
:zoneCheck
: Whether this collider should be used to detect if entity is within zone. Defaults to false.CollisionComponentData
:zoneCheck
: Whether this collider should be used to detect if entity is within zone. Defaults to false.I also think that it would be nice to have an
effects
property onZoneComponent
with some predefined effects such as Audio Reverb or Force like some other game engines but I think the component itself is a first thing to get approved before going further.CollisionComponent#zoneCheck
andZoneComponent#useColliders
are set tofalse
by default to optimize. Users must only enable when needed (character for example) to reduce calculations. May you want to play a bit with it just fork https://playcanvas.com/project/1045217 and add whatever script you might need to test it out.Note: This PR is ready for review. Draft status is only because it requires another PR before being added.
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.