Chataigne/Assets/Script/Parralax.cs
Djalim Simaila 36a2982a48 IMPORTATION_CODE
Code parralax des décors
Ajout et correction du code Hadès
2023-05-30 20:24:37 +02:00

24 lines
689 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Parralax : MonoBehaviour
{
private float length, startpos;
[SerializeField] private GameObject cam;
[SerializeField] private float parallaxEffect = 0;
// Start is called before the first frame update
void Start()
{
startpos = transform.position.x;
length = GetComponent<SpriteRenderer>().bounds.size.x;
}
// Update is called once per frame
void FixedUpdate()
{
float dist = (cam.transform.position.x * parallaxEffect);
transform.position = new Vector3(startpos + dist, transform.position.y, transform.position.z);
}
}