Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Bolt;
- public class Character : Bolt.EntityEventListener<IPlayerState>
- {
- private CharacterController controller;
- [SerializeField]
- private CharacterMotor motor;
- private void Start()
- {
- controller = GetComponent<CharacterController>();
- motor = GetComponent<CharacterMotor>();
- //motor = new CharacterMotor(motor, controller, transform);
- }
- public override void Attached()
- {
- state.SetTransforms(state.PlayerTransform, transform);
- }
- public override void SimulateController()
- {
- IPlayerCommandInput input = PlayerCommand.Create();
- input.horizontal = Input.GetAxis("Horizontal");
- input.vertical = Input.GetAxis("Vertical");
- input.jump = Input.GetKey(KeyCode.Space);
- entity.QueueInput(input);
- }
- public override void ExecuteCommand(Command command, bool resetState)
- {
- PlayerCommand cmd = (PlayerCommand)command;
- if(resetState)
- {
- motor.MoveLocal(cmd.Result.velocity);
- }
- else
- {
- motor.Move(cmd.Input.horizontal, cmd.Input.vertical, cmd.Input.jump);
- cmd.Result.position = transform.position;
- cmd.Result.velocity = motor.movement;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement