UE4 blueprint simulation transport unit process “Put an elephant in the fridge and take it out of the fridge”

Ready: a small car that can move NPC unitsCopy the code

Move the NPC to the cart

First you need to get the location of the clickCopy the code

Then Move to Location or actorCopy the code

When the NPC enters the car, the set of SelectedUnit will be cleared, and then a null pointer will return. Although it will not crash, the background will record the situation. If you overlap choose falseCopy the code
StateDiagram -v2 [*] --> NPC move NPC move --> Bump into car Car bump into car --> Keep marking time keep marking time --> Unable to reach the specified point, unable to get on the car
In this case, the range of judgment is increased, and the judgment is made before the NPC reaches the specified point, eliminating the possibility of bumping into carsCopy the code
StateDiagram -v2 [*] --> NPC move NPC move --> Bump into car car bump into car --> keep pedalling keep pedalling --> Unable to reach specified point, Unable to move the ONBOARD NPC --> into the onboard range --> The NPC into the car

The NPC gets into the car

Passengers will be arriving one by one from NPC, selectedUnits. If the hit unit is a small car, and the car can also put units into the next set unit movement operationCopy the code

Get on this behavior in the game is to have cultured, because there will be a collision between model, your car car mostly is a cuboid, a bit better in the middle of the can to pull on the sides, NPC if enter the trolley car, that their model is directly overlap, of course you can pay attention to point to the trolley car directly to the internal model, reset the collision volume, Create a passenger behavior here is a simple way to direct the hidden AND Teleport NPC as the action of getting on the bus. The current situation is thisCopy the code
StateDiagram -v2 [*] --> NPC move NPC move --> Bump into car car bump into car --> keep pedalling keep pedalling --> Unable to reach specified point, Unable to get into the car NPC move --> Get into the car range Get into the car range -->NPC get into the car NPC get into the car -->NPC Invisibility NPC Invisibility -->NPC move to the bottom of the map
This is similar to the corpse behavior in Moba games, where the corpse sinks under the map and destory. But it's just sitting there, nothing else.Copy the code

The NPC jumps out of the car

Last time it was a stone monkey, here it's a red and blue man. RemovePassengers Function UnitCarCopy the code

This is the reverse of putting the elephant in the fridge, but doing this directly will result in the character standing still at the bottom of the mapCopy the code
StateDiagram -v2 [*] --> NPC move NPC move --> Bump into car car bump into car --> keep pedalling keep pedalling --> Unable to reach specified point, Unable to get on the NPC move --> Enter the vehicle range enter the vehicle range -->NPC enter the car vehicle NPC enter the vehicle -->NPC invisible NPC invisible -->NPC move to the bottom of the map NPC move to the bottom of the map --> Execute RemovePassengers NPC passengers are still under the map, cars are empty, NPC is not present
It can be found that the Teleport command was not successfully executed because the model overlapped and the two figures overlapped with the car. The Teleport command was not directly executed, so the pop-up setting was adoptedCopy the code
StateDiagram -v2 [*] --> NPC move NPC move --> Bump into car car bump into car --> keep pedalling keep pedalling --> Unable to reach specified point, Unable to get on the NPC move --> Enter the vehicle range enter the vehicle range -->NPC enter the car vehicle NPC enter the vehicle -->NPC invisible NPC invisible -->NPC move to the bottom of the map NPC move to the bottom of the map --> Execute RemovePassengers NPC passengers are still under the map. NPC passengers are still under the map. NPC passengers are still under the map. NPC does not appear --> NPC collides with trolley --> Teleport fails NPC display --> NPC jumps out of a place 3 meters above trolley --> No collision with trolley No collision with small car --> Teleport executed successfully

The NPC that pops out