Building city
This commit is contained in:
@@ -1,37 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraPlayerFollow : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform _player;
|
||||
|
||||
private Vector3 _cameraOffset;
|
||||
|
||||
private Transform _obstruction;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0.01f, 1.0f)]
|
||||
private float _smoothFactor = 0.5f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_obstruction = null;
|
||||
_cameraOffset = transform.position - _player.position;
|
||||
transform.LookAt(_player);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
Vector3 newPosition = _player.position + _cameraOffset;
|
||||
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
|
||||
ViewObstructed();
|
||||
}
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraPlayerFollow : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform _player;
|
||||
|
||||
private Vector3 _cameraOffset;
|
||||
|
||||
private Transform _obstruction;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0.01f, 1.0f)]
|
||||
private float _smoothFactor = 0.5f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_obstruction = null;
|
||||
_cameraOffset = transform.position - _player.position;
|
||||
transform.LookAt(_player);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
Vector3 newPosition = _player.position + _cameraOffset;
|
||||
|
||||
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
|
||||
ViewObstructed();
|
||||
}
|
||||
|
||||
private void ViewObstructed()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position, _player.position - transform.position, out hit, 1.5f))
|
||||
if (Physics.Raycast(transform.position, _player.position - transform.position, out hit, 3.5f))
|
||||
{
|
||||
if (hit.collider.gameObject.tag != "Player")
|
||||
{
|
||||
@@ -44,5 +44,5 @@ public class CameraPlayerFollow : MonoBehaviour
|
||||
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
||||
_obstruction = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,10 @@ public class PlayerManager : MonoBehaviour
|
||||
targetDest.Stop();
|
||||
if (Physics.Raycast(myRay, out RaycastHit hit))
|
||||
{
|
||||
|
||||
targetDest.transform.position = hit.point;
|
||||
player.SetDestination(hit.point);
|
||||
var pos=hit.point;
|
||||
pos.y += 0.2f;
|
||||
targetDest.transform.position = pos;
|
||||
player.SetDestination(pos);
|
||||
targetDest.Play();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user