Hello, im trying to move my gameobject in the scene at different speed with their tag, i got a little problem i dont know how to make the calcul during transform: i want to have a reference speed like 100 and 3 different rate for my different tags like 1, 0.5 or 0.25
using UnityEngine;
using System.Collections;
public class SceneManager : MonoBehaviour {
public float layerFrontSpeed;
public float layerMediumSpeed;
public float layerFarSpeed;
public float RefSpeed;
public GameObject[] layerFrontGO;
public GameObject[] layerMediumGO;
public GameObject[] layerFarGO;
// Use this for initialization
void Start () {
UpdateGOList ();
}
void UpdateGOList ()
{
layerFrontGO = GameObject.FindGameObjectsWithTag("FrontGO");
layerMediumGO = GameObject.FindGameObjectsWithTag("MediumGO");
layerFarGO = GameObject.FindGameObjectsWithTag("FarGO");
}
// Update is called once per frame
void Update () {
foreach(GameObject obj in layerFrontGO)
{
var temp = obj.transform.position;
temp =RefSpeed*layerFrontSpeed;
obj.transform.position.x = new Vector3(temp,0.0f,0.0f);
}
foreach(GameObject obj in layerMediumGO)
{
//obj.transform.position.x = RefSpeed*layerMediumSpeed;
}
foreach(GameObject obj in layerFarGO)
{
//obj.transform.position.x = RefSpeed*layerFarSpeed;
}
}
}
i got this errors, but i didnt found a way to make it work:(
would love some help!
Assets/Scripts/SceneManager.cs(31,25): error CS0029: Cannot implicitly convert type float' to
UnityEngine.Vector3’
Assets/Scripts/SceneManager.cs(32,79): error CS1502: The best overloaded method match for UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments Assets/Scripts/SceneManager.cs(32,79): error CS1503: Argument
#1’ cannot convert UnityEngine.Vector3' expression to type
float’
Assets/Scripts/SceneManager.cs(32,39): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable