Question by
matt_unity694 · Jan 31 at 10:30 AM ·
scripting problemvariable
Mulit script variable not connecting
I have been trying to send the public variable Room_move from my script Movement_jump.cs to Camera_movement.cs. Here is the code in Movement_jump.cs
public class Movement_jump : MonoBehaviour
{
public float Starting_x, Starting_y;
public int Jump_distance;
float x_current, y_current;
string currentroom;
public string Room_move;
// public gameObject CameraMove;
// void start()
// {
// Camera = gameObject.Find("Camera_movement");
// }
// Start is called before the first frame update
void Start()
{
gameObject.transform.Translate(Starting_x, Starting_y, -1);
currentroom = "room1";
}
// Update is called once per frame
void Update()
{
if (currentroom == "room1")
{
x_current = gameObject.transform.position.x;
y_current = gameObject.transform.position.y;
}
if (currentroom == "room2")
{
x_current = gameObject.transform.position.x;
y_current = gameObject.transform.position.y - 8;
}
// Debug.Log((int)x_current);
if (Input.GetKeyDown(KeyCode.UpArrow))
{
if (Rooms.Room1[(int)y_current + 1, (int)x_current] == 0)
{
gameObject.transform.Translate(0, Jump_distance, 0);
}
if (Rooms.Room1[(int)y_current + 1, (int)x_current] == 1)
{
}
if (Rooms.Room1[(int)y_current + 1, (int)x_current] == 2)
{
gameObject.transform.Translate(0, Jump_distance + 1, 0);
Room_move = "up";
}
}
This is the program that I am trying to call Room_move in: using UnityEngine;
public class Camera_movement : MonoBehaviour
{
public GameObject Dude;
public string test;
UnityEngine.Component room_move_script;
string room_move;
void start()
{
Dude = gameObject.Find("dude");
// Movement_jump Screenmove = Dude.GetComponent<Movement_jump>();
}
void update()
{
Movement_jump Screenmove = Dude.GetComponent<Movement_jump>();
if (Screenmove.Room_move == "up")
{
Debug.Log("yay");
}
}
}
The First script is on a object named dude, and the second is on a camera.
Is there anything that I am doing wrong?
Comment