Hello,
I work on easy adventure game on android, before i started working on “Hovering” script game work without any lags in my mobile (samsung galaxy A5) because there is nothing just player, one enemy that aim on you and shoot and platforms plus some pickable objects for mana and healh. Then i wanted to make those pickable objects more interesting, because its in air then i want to make it hover. But when i copy this hovering objects ±10x then it start laging on mobile. (i dont know on how FPS it work because my mobile cant show me it and i dont find nothing to show fps)…
Here is this howering script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hovering : MonoBehaviour {
public float horizontalSpeed;
public float verticalSpeed;
public float amplitude;
private Vector3 tempPosition;
private float delay;
void Start () {
tempPosition = transform.position;
delay = Random.Range(0.9f, 1.1f);
}
private void Update()
{
Hover();
}
private void Hover ()
{
transform.position = tempPosition + new Vector3(0, Mathf.Sin(Time.time * (verticalSpeed * delay)) * (amplitude * delay) , 0);
}
}
My question is, why is the script so demanding for mobile, and how can i do it easier if its posible.
Thx