Player Controller for top-down games
This system allows you to easily implement cool player controlling for top-down games (like Diablo):
- Control player by mouse (or other input device)
- Manage/direct and perform all interactions with game-objects (enemies, NPCs, pick-ups, locks etc)
- Link and manage animation related for those interactions
- Support movement both on custom geometry/collider and Terrain objects
Moreover, it’s really easy to extend the system and implement any new actions you may need in game.
This system works on all platforms supported by Unity3D.
To use this system – you should:
1st option (auto):
Delete default MainCamera in scene
Add(drag and drop) all prefabs from “_TopDown_PlayerController\Prefabs\” to Hierarchy window
If needed – replace default player model (Lerpz) to another and update AnimatedObject property of
“PlayerDirector” component (in _Player object) accordingly.
2nd option (manual):
Create new object with Rigidbody and Collider (IsTrigger = true) attached, attach “GameCursor” component to it. It will be our cursor.
Create new object (with Rigidbody and Collider if needed) and attach “InputManager”, “PlayerController” and “PlayerDirector” components to it. It will be our player.
Attach “FollowingCamera” component to MainCamera and place camera and assign player object object to it target property. (Object should be visible in camera view, cuz camera always tries to keep initial offset against the player)
Assign cursor object and “InputManager”, “PlayerDirector” components to related properties of “PlayerController” component (in _Player object).
Add child object (with animation) to player object and assign it to AnimatedObject property of “PlayerDirector” component.
Setup needed actions in Actions list of “PlayerController” component.
Objects to interact - should have custom Tag, same as in “triggeredObjectTag” variable of related actions.
To create brand new action type – you should add it to ActionTypes list in “PlayerController” script and add related function with the same name in “PlayerDirector” script.