- Home /
Question by
Sayden96 · Nov 28, 2021 at 04:05 PM ·
effectparametersparallaxslowdown
Slowdown in Parallax
I create a Quad to use to background and have the parallax effect by script but when i play the game i have a little slowdown when the player moves. How i can resolve this? The parallax script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Parallax : MonoBehaviour
{
Material material;
Vector2 offset;
public Rigidbody2D rb;
public float xVelocity, yVelocity;
private void Awake()
{
material = GetComponent<Renderer>().material;
}
void Update()
{
offset = new Vector2(xVelocity, yVelocity);
material.mainTextureOffset += offset * Time.deltaTime;
Vector3 vel = transform.rotation * rb.velocity;
if (vel.x > 0)
{
// right
xVelocity = .1f;
}
else if (vel.x < 0)
{
// left
xVelocity = -.1f;
}
else if (vel.x == 0)
{
xVelocity = .0f;
}
}
Comment
Your answer

Follow this Question
Related Questions
How to make a portal effect texture? 2 Answers
Bullet hit effect take the color of the material color 0 Answers
ui animation effect 0 Answers
Partilcle effect help needed 2 Answers
Shaders: Overwrite something? 1 Answer