Import 2D Level
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Platformer.View
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to move a transform relative to the main camera position with a scale factor applied.
|
||||
/// This is used to implement parallax scrolling effects on different branches of gameobjects.
|
||||
/// </summary>
|
||||
public class ParallaxLayer : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Movement of the layer is scaled by this value.
|
||||
/// </summary>
|
||||
public Vector3 movementScale = Vector3.one;
|
||||
|
||||
Transform _camera;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_camera = Camera.main.transform;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
transform.position = Vector3.Scale(_camera.position, movementScale);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user