Dear Forum,
I am an experienced 3D animator but only a C# beginner and I have a (probably) very simple problem which I can´t solve on my own.
In a nutshell:
I have 4 objects (players) and three buttons placed between them. On clicking the buttons I want the objects left and right of the button to switch their positions. Due to the fact that the objects will be passed from button to button I need to check their positions and then decide wether to move them or not. The buttons call the SwitchPos() on click and the script is placed on a parent empty game object and checks the objects by their tag “asset3_objects”. Currently I only have one if clause running checking if an object has transform.x equals 4 and needs to be moved to 7
I use the following script:
using UnityEngine;
using System.Collections;
public class asset2_master_v2 : MonoBehaviour
{
public GameObject[] players;
public void SwitchPos()
{
players = GameObject.FindGameObjectsWithTag("asset3_objects");
for (int i = 0; i < players.Length; i++)
{
// Debug.Log("Player Number " + i + " is named " + players*.transform.position.x);*
if(players*.transform.position.x==4)*
{
Debug.Log(“Object Number” + i + “fits”);
private float timeElapsed;
private float lerpDuration = 30f;
private float startValue = 4;
private float endValue = 7;
private float valueToLerp = players*.transform.position.x;*
valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);
timeElapsed += Time.deltaTime;
}
}
}
}
The Debug Log tells me that the object fits the position. Now when I add the Lerp components things start to go sideways and I get the error codes:
Assets\scripts\asset3\asset2_master_v2.cs(28,15): error CS1519: Invalid token ‘.’ in class, struct, or interface member declaration
Assets\scripts\asset3\asset2_master_v2.cs(28,36): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration
Where do I go wrong? I am probably pretty close but I am still learning and do not have the necessary knowledge to solve this on my own. I have read a bit on the Lerp function but the tutorials and documentation cover topics which are a lot more complex than this.
Thank you and best regards
Dunkel-san