Looking to make a specific gameobject be set to active and move to a specific position for an OnClick function. Everything works except the Transform.Position, as soon as I try to implement it, the Gameobject, which ordinarily is set to active OnClick, actually just completely disappears.
For context, the gameobject is ordinarily positioned at -278, 742, 0. And needs to move to -253, 483, 0 when the script runs it’s if statement and finds the bool to be true. It’s a 2D project, so I don’t actually need to use Vector3, but in all the examples I’ve found, it just seems to be the staple everyone is using regardless. Changing the Z value doesn’t change anything as far as visibility is concerned.
I’m not really sure what I’m doing wrong here. I’m sure that the solution is going to be really stupidly simple, or completely out of my league, haha, so any help would be appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
public class isActive : MonoBehaviour
{
bool Home = true;
public GameObject YouAreHere;
public Button DeactivatedButton;
public GameObject ToMove;
// Start is called before the first frame update
void Start()
{
if(Home == true)
{
Debug.Log("You're at home already!");
YouAreHere.SetActive(true);
DeactivatedButton.interactable = false;
ToMove.transform.position = new Vector3(-253f, 483f, 0f);
}
else
{
Debug.Log("Well, look at that, you aren't at home!");
YouAreHere.SetActive(false);
DeactivatedButton.interactable = true;
}
}