Commit 79ba2f6a authored by bogomil's avatar bogomil

Merge branch 'master' of...

Merge branch 'master' of gitlab.fsi.hochschule-trier.de:GameDevWeek/sommersemester-2019/unity/touch-me-if-you-can
parents ebdf89f6 17f8d808
......@@ -60,7 +60,7 @@ MonoBehaviour:
m_TypeName: UnityEngine.InputSystem.PlayerInput+DeviceRegainedEvent, Unity.InputSystem,
Version=0.9.6.0, Culture=neutral, PublicKeyToken=null
m_NeverAutoSwitchControlSchemes: 1
m_DefaultControlScheme: Keyboard
m_DefaultControlScheme: Gamepad
m_DefaultActionMap: 480005df-eb34-4300-80ff-96103380a4f8
m_SplitScreenIndex: -1
m_Camera: {fileID: 0}
......
......@@ -204,11 +204,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
canMove: 1
moveSpeed: 5
moveSpeed: 8
maxSpeed: 10
dir: {x: 0, y: 0}
interpolation: 10
turnSpeed: 200
turnSpeed: 5
--- !u!114 &1957649875713174593
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -604,6 +604,11 @@ PrefabInstance:
propertyPath: m_Name
value: Player1Manager
objectReference: {fileID: 0}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 944714734}
- target: {fileID: 4412139409271564331, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -659,11 +664,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 944714734}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 63e8800253376df44a1d2ea9ad6b520a, type: 3}
--- !u!1001 &6176636124327810795
......@@ -757,6 +757,11 @@ PrefabInstance:
propertyPath: m_Name
value: Player2Manager
objectReference: {fileID: 0}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 1655921399}
- target: {fileID: 5204299803420509725, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -822,10 +827,5 @@ PrefabInstance:
propertyPath: m_NeverAutoSwitchControlSchemes
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 1655921399}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 276ed99a0fe19ff48b6ad175cbbec559, type: 3}
......@@ -1395,6 +1395,11 @@ PrefabInstance:
propertyPath: m_Name
value: Body
objectReference: {fileID: 0}
- target: {fileID: 5454309568428411407, guid: ea05ca32432105d468969c2ccef55e1a,
type: 3}
propertyPath: turnSpeed
value: 5
objectReference: {fileID: 0}
- target: {fileID: 2301140017794985288, guid: ea05ca32432105d468969c2ccef55e1a,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -1544,6 +1549,16 @@ PrefabInstance:
propertyPath: m_Name
value: Player2Manager
objectReference: {fileID: 0}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 1302136059}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: mutation
value:
objectReference: {fileID: 1302136066}
- target: {fileID: 5204299803420509725, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -1609,16 +1624,6 @@ PrefabInstance:
propertyPath: m_DefaultActionMap
value: 38732b26-d9e3-4196-a316-9054667e9b3d
objectReference: {fileID: 0}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 1302136059}
- target: {fileID: 5204299803420509727, guid: 276ed99a0fe19ff48b6ad175cbbec559,
type: 3}
propertyPath: mutation
value:
objectReference: {fileID: 1302136066}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 276ed99a0fe19ff48b6ad175cbbec559, type: 3}
--- !u!1 &1134165135
......@@ -2951,21 +2956,6 @@ PrefabInstance:
propertyPath: m_textInfo.pageCount
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: player
value:
objectReference: {fileID: 1302136065}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: myCamera
value:
objectReference: {fileID: 1493510237}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: mainCam
value:
objectReference: {fileID: 1493510237}
- target: {fileID: 2262339500835830697, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: m_textInfo.characterCount
......@@ -2991,6 +2981,21 @@ PrefabInstance:
propertyPath: m_textInfo.pageCount
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: player
value:
objectReference: {fileID: 1302136065}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: myCamera
value:
objectReference: {fileID: 1493510237}
- target: {fileID: 2262339500692566933, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: mainCam
value:
objectReference: {fileID: 1493510237}
- target: {fileID: 2262339500835830694, guid: a110348e88a7b5d4c99fc9cf97d69e3e,
type: 3}
propertyPath: player
......@@ -3095,6 +3100,16 @@ PrefabInstance:
propertyPath: m_Name
value: Player1Manager
objectReference: {fileID: 0}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 35336290}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: mutation
value:
objectReference: {fileID: 35336296}
- target: {fileID: 4412139409271564331, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -3160,16 +3175,6 @@ PrefabInstance:
propertyPath: m_DefaultActionMap
value: 480005df-eb34-4300-80ff-96103380a4f8
objectReference: {fileID: 0}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: movement
value:
objectReference: {fileID: 35336290}
- target: {fileID: 4412139409271564309, guid: 63e8800253376df44a1d2ea9ad6b520a,
type: 3}
propertyPath: mutation
value:
objectReference: {fileID: 35336296}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 63e8800253376df44a1d2ea9ad6b520a, type: 3}
--- !u!1001 &616821673859321438
......
......@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a85af5fac3731724dab4797931b89571, type: 3}
m_Name: GameManagerData
m_EditorClassIdentifier: Assembly-CSharp:_Game.Scripts.GameManagerData:GameManagerData
timeLeft: 3.98
timeLeft: 30
roundTime: 30
roundsToPlay: 4
roundsPlayed: 0
......@@ -29,8 +29,8 @@ MonoBehaviour:
lastRoundTimeLeft: 0
lastRoundWonByCatching: 0
lastGameScorePoints: 45.756027
player1ScorePoints: 3.98
player2ScorePoints: 0.01999998
player1ScorePoints: 30
player2ScorePoints: 0
sidesChanged: 0
player1Name: Jonas
player2Name: Bogi
......
......@@ -5,12 +5,15 @@ using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Users;
using UnityEngine.Serialization;
namespace _Game.Scripts.Movement {
public class BodyMovement : MovementBase {
namespace _Game.Scripts.Movement
{
public class BodyMovement : MovementBase
{
[SerializeField] private float interpolation = 10;
[SerializeField] private float turnSpeed = 200;
private float _currentRotation = 0;
private Quaternion _rot;
private Vector2 _currentDir;
private bool _isRunning = false;
......@@ -18,42 +21,57 @@ namespace _Game.Scripts.Movement {
private PlayerInput _input;
private Animator _animator;
public float TurnSpeed {
public float TurnSpeed
{
get => turnSpeed;
set => turnSpeed = value;
}
protected override void Start() {
protected override void Start()
{
base.Start();
_animator = GetComponent<Animator>();
_input = GetComponent<PlayerInput>();
}
private void FixedUpdate() {
private void FixedUpdate()
{
Movement();
ClampVelocity();
//_animator.SetBool("running", _isRunning);
}
public override void OnMovement(InputValue value) {
public override void OnMovement(InputValue value)
{
var v = value.Get<Vector2>();
dir = (Invert) ? new Vector2(v.x * -1, v.y) : v;
}
private void Movement() {
_currentDir = new Vector2(Mathf.Lerp(_currentDir.x, dir.x, Time.fixedDeltaTime * interpolation),
Mathf.Lerp(_currentDir.y, dir.y, Time.fixedDeltaTime * interpolation));
_currentRotation += _currentDir.x * turnSpeed * Time.fixedDeltaTime;
_rigidbody.rotation = Quaternion.Euler(new Vector3(0, _currentRotation, 0));
if (!(dir.y > 0) || !canMove) {
_isRunning = false;
return;
private void Movement()
{
// _currentDir = new Vector2(Mathf.Lerp(_currentDir.x, dir.x, Time.fixedDeltaTime * interpolation),
// Mathf.Lerp(_currentDir.y, dir.y, Time.fixedDeltaTime * interpolation));
// _currentRotation += _currentDir.x * turnSpeed * Time.fixedDeltaTime;
// _rigidbody.rotation = Quaternion.Euler(new Vector3(0, _currentRotation, 0));
//
// if (!(dir.y > 0) || !canMove) {
// _isRunning = false;
// return;
// }
//
// _isRunning = true;
// var move = _currentDir.y * MoveSpeed * transform.forward;
// _rigidbody.velocity = new Vector3(move.x, 0f, move.z);
if (dir.sqrMagnitude != 0)
{
_rot = Quaternion.LookRotation(new Vector3(dir.x, 0, dir.y), Vector3.up);
}
_isRunning = true;
var move = _currentDir.y * MoveSpeed * transform.forward;
_rigidbody.velocity = new Vector3(move.x, 0f, move.z);
_rigidbody.rotation = Quaternion.RotateTowards(_rigidbody.rotation, _rot.normalized, turnSpeed);
var angle = Quaternion.Angle(_rigidbody.rotation, _rot);
float percentageAngle = angle / 180f;
_rigidbody.velocity = Mathf.Lerp(0, MoveSpeed, (1 - percentageAngle)) * new Vector3(dir.x, 0, dir.y);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment