I used the relevant code from this project, cleaning it up and turning it into an editor asset that could be used to bake animations. Unity utilized this technique for their Nordeus demo showcasing ECS, and Joachim Ante created a GitHub project that isolated this specific functionality. Since there is only one hero character on screen at a time, the performance cost here was negligible. I did, however, decide to use the GameObject approach for the hero character, because we required animation blending and IK for the arms to hold the weapon. I chose the later option primarily for performance reasons, as interfacing between ECS and GameObjects isn’t efficient for large amounts of entities. Stupid zombies unblocked skin#Use a shader to skin the mesh on the GPU. Though this would have worked, in many ways it would have defeated the purpose of using ECS altogether. Stupid zombies unblocked update#Use ECS to update the zombies’ navigation and AI, but have each represented by a GameObject in the scene. With this limitation, we had a couple of options: You can read more about the Hybrid Renderer package and the differences between the two versions here). For this project, we used Hybrid Renderer V1. Unfortunately, when the project began, Unity did not support skinned mesh animation for entities in any capacity (this feature is supported to some extent now, though primarily for Hybrid Renderer V2, which is not yet available for use on mobile. One of the main appeals of ECS is the ability to have a high volume of entities simultaneously simulating on the screen. Private void UpdateDirection(ushort neighborSpace, byte neighborDirectionIndex, ref byte lowestCost, ref byte directionIndex)īyte neighborCost = spaceCosts UpdateDirection(GetNeighborSpaceDownRight(space, dimensions), _downRightDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceDownLeft(space, dimensions), _downLeftDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceUpRight(space, dimensions), _upRightDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceUpLeft(space, dimensions), _upLeftDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceRight(space, dimensions), _rightDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceLeft(space, dimensions), _leftDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceDown(space, dimensions), _downDirectionIndex, ref lowestCost, ref directionIndex) UpdateDirection(GetNeighborSpaceUp(space, dimensions), _upDirectionIndex, ref lowestCost, ref directionIndex) Public NativeArray spaceDirectionIndices Private struct AssignNavigationDirectionsJob : IJobParallelFor If (spaceCosts = byte.MaxValue)Įlse if (cost < spaceCosts) Private void ProcessNeighbor(NativeQueue pendingSpaces, ushort neighborSpace, byte cost) ProcessNeighbor(pendingSpaces, GetNeighborSpaceDownRight(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.DownRight)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceDownLeft(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.DownLeft)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceUpRight(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.UpRight)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceUpLeft(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.UpLeft)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceRight(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.Right)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceLeft(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.Left)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceDown(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.Down)) ProcessNeighbor(pendingSpaces, GetNeighborSpaceUp(space, dimensions), neighborCost) If (CanGoDirection(openDirections, GridDirectionFlags.Up)) GridDirectionFlags openDirections = openSpaceDirections īyte neighborCost = (byte)math.min(spaceCosts + 1, byte.MaxValue) NativeQueue pendingSpaces = new NativeQueue(Allocator.Temp) Private struct AssignNavigationCostsJob : IJob
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |