Post by Admin on Jul 16, 2016 4:24:37 GMT
William Taylor @willt Sep 04 2015 10:19
Has anyone made a detailed tutorial on Entitas w/ Unity? I'm struggling right now with converting my player controller over to use it. Trying to figure out how you would set it up with a player that uses a rigid body for movement. Like right now I have a PlayerController that in FixedUpdate() Gets a Vector2 movementVector of Input.GetAxisRaw adjusts the the rotation of the transform, start/stops walking animation and finally calls Rigidbody2D.MovePosition(curPos + (movementVector movementSpeed) Time.deltaTime); How would that translate over to Entitas ?
Maxim Zaks @mzaks Sep 04 2015 16:23
We thought about making a step by step tutorial but we haven't done it yet.
If you have some specific question that would be easier to answer here, other wise I can try to make it in more abstract level but I realise that it is hard to under.
On an abstract level you would have to create a component which links to the game object which is your character with rigid body, this is helpful so that you can query for the game object easily when you want to change its position in the world (you can do it also by searching the scene but this is normally slow). Than it is better to have a special component for movementVector and in PlayerController just create an entity which has this component added.
Than you can have one or multiple reactive systems which can react on entities with MovementVectorComponent being created (added to the group which monitors entities with MovementVectorComponent) and start/stop animations adjust transforms and move the game objects which should be movable by this event.
This is kind of how it transforms to Entitas. The most important things are that you represent input as components, by this you create additional game state, and than you react on new game state by transforming some other game state.
Here is the ProcessInputSystem from MatchOne example
github.com/sschmid/Match-One/blob/master/Assets/Sources/Features/Input/ProcessInputSystem.cs
it basically does the same they I just described
And here is the input controller which creates the entity with InputConponent
github.com/sschmid/Match-One/blob/master/Assets/Scripts/InputController.cs
I hope this helps. If you have more questions don't hesitate to ask.
And we will try to make some tutorials soon. Or maybe someone from the community would like to contribute?
Has anyone made a detailed tutorial on Entitas w/ Unity? I'm struggling right now with converting my player controller over to use it. Trying to figure out how you would set it up with a player that uses a rigid body for movement. Like right now I have a PlayerController that in FixedUpdate() Gets a Vector2 movementVector of Input.GetAxisRaw adjusts the the rotation of the transform, start/stops walking animation and finally calls Rigidbody2D.MovePosition(curPos + (movementVector movementSpeed) Time.deltaTime); How would that translate over to Entitas ?
Maxim Zaks @mzaks Sep 04 2015 16:23
We thought about making a step by step tutorial but we haven't done it yet.
If you have some specific question that would be easier to answer here, other wise I can try to make it in more abstract level but I realise that it is hard to under.
On an abstract level you would have to create a component which links to the game object which is your character with rigid body, this is helpful so that you can query for the game object easily when you want to change its position in the world (you can do it also by searching the scene but this is normally slow). Than it is better to have a special component for movementVector and in PlayerController just create an entity which has this component added.
Than you can have one or multiple reactive systems which can react on entities with MovementVectorComponent being created (added to the group which monitors entities with MovementVectorComponent) and start/stop animations adjust transforms and move the game objects which should be movable by this event.
This is kind of how it transforms to Entitas. The most important things are that you represent input as components, by this you create additional game state, and than you react on new game state by transforming some other game state.
Here is the ProcessInputSystem from MatchOne example
github.com/sschmid/Match-One/blob/master/Assets/Sources/Features/Input/ProcessInputSystem.cs
it basically does the same they I just described
And here is the input controller which creates the entity with InputConponent
github.com/sschmid/Match-One/blob/master/Assets/Scripts/InputController.cs
I hope this helps. If you have more questions don't hesitate to ask.
And we will try to make some tutorials soon. Or maybe someone from the community would like to contribute?