Creating a Parallaxe in a scrolling 2d game by tag.

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

Hi

Assets/Scripts/SceneManager.cs(31,25): error CS0029: Cannot implicitly convert type float' to UnityEngine.Vector3’
obj.transform.position is a vector3
try

 var temp = obj.transform.position.x;

            temp =RefSpeed*layerFrontSpeed;

thank you!

i changed my update this way:

void Update () {
		
		foreach(GameObject obj in layerFrontGO)
		{
			var temp = obj.transform.position.x;
		
			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;
		}
	
	}

but i still have two error:

Assets/Scripts/SceneManager.cs(33,39): error CS1612: Cannot modify a value type return value of UnityEngine.Transform.position'. Consider storing the value in a temporary variable Assets/Scripts/SceneManager.cs(33,48): error CS0029: Cannot implicitly convert type UnityEngine.Vector3’ to `float’

i dont know why i think im storing correctly the vector3 in a new variable

You are doing the same error ^^

obj.transform.position.x = new Vector3(temp,0.0f,0.0f);
you have to think , what is obj.transform.position.x … it’s a float
and new Vector3 is … well a vector3 ^^
try

obj.transform.position = new Vector3(temp,0.0f,0.0f); // obj.transform.position is a vector3 so I set it to a vector3

Good luck

keep practicing

oh found my error i changed here:

obj.transform.position += new Vector3(temp,0.0f,0.0f);