Merge remote-tracking branch 'origin/Over' into Syntriax
This commit is contained in:
8
Assets/Scripts/Camera.meta
Normal file
8
Assets/Scripts/Camera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1dd4ed9ed15bfbe4e826cb0763b86e43
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/Scripts/Camera/CameraPlayerFinder.cs
Normal file
21
Assets/Scripts/Camera/CameraPlayerFinder.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Camera
|
||||
{
|
||||
public class CameraPlayerFinder : MonoBehaviour
|
||||
{
|
||||
private CinemachineVirtualCamera _cinemachineVirtualCamera;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cinemachineVirtualCamera = GetComponent<CinemachineVirtualCamera>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_cinemachineVirtualCamera.Follow == null && GameObject.FindWithTag("Player") != null)
|
||||
_cinemachineVirtualCamera.Follow = GameObject.FindWithTag("Player").transform;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Camera/CameraPlayerFinder.cs.meta
Normal file
11
Assets/Scripts/Camera/CameraPlayerFinder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca616a2edfacfd54fb236cd92b9e2dea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -17,10 +17,12 @@ namespace Platforms
|
||||
private bool _goingToFuturePos;
|
||||
|
||||
private Rigidbody2D _platformRigidbody;
|
||||
private CollisionChecker _movingPlatformTrigger;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_platformRigidbody = GetComponent<Rigidbody2D>();
|
||||
_movingPlatformTrigger = GetComponentInChildren<CollisionChecker>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -58,19 +60,22 @@ namespace Platforms
|
||||
|
||||
public void Move(float value)
|
||||
{
|
||||
var position = transform.position;
|
||||
//var position = transform.position;
|
||||
switch (_goingToFuturePos)
|
||||
{
|
||||
case true:
|
||||
_platformRigidbody.MovePosition(new Vector2(position.x + speed * GetDecision(xOffset),
|
||||
position.y + speed * GetDecision(yOffset)));
|
||||
//_platformRigidbody.MovePosition(new Vector2(position.x + speed * GetDecision(xOffset),
|
||||
//position.y + speed * GetDecision(yOffset)));
|
||||
|
||||
transform.position = Vector3.MoveTowards(transform.position, _futurePos, speed * Time.deltaTime);
|
||||
if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset &&
|
||||
Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset)
|
||||
_goingToFuturePos = false;
|
||||
break;
|
||||
case false:
|
||||
_platformRigidbody.MovePosition(new Vector2(position.x + speed * -GetDecision(xOffset),
|
||||
position.y + speed * -GetDecision(yOffset)));
|
||||
//_platformRigidbody.MovePosition(new Vector2(position.x + speed * -GetDecision(xOffset),
|
||||
//position.y + speed * -GetDecision(yOffset)));
|
||||
transform.position = Vector3.MoveTowards(transform.position, _originalPos, speed * Time.deltaTime);
|
||||
if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset &&
|
||||
Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset)
|
||||
_goingToFuturePos = true;
|
||||
|
Reference in New Issue
Block a user