Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

how to input parameter into game object? please help

Discussion in 'Unity Connect' started by cclate1, Dec 26, 2016.

  1. cclate1

    cclate1

    Joined:
    Dec 26, 2016
    Posts:
    2
    for example:

    using UnityEngine;
    using System.Collections;

    public class BuildingPlacement : MonoBehaviour {
    public GameObject currentPeople;
    public int DelayTime;
    private int timeCount;
    }


    if i want to say that
    DelayTime = currentPeople.timeCount;
    i try this one and it doesnt work:
    DelayTime = (BuildingPlacement)currentPeople.GetComponent(typeof(BuildingPlacement));

    How do i get the value of currentPeople.timeCount ? is it possible?
     
  2. markp-unity

    markp-unity

    Joined:
    Nov 3, 2015
    Posts:
    294
    Hey cclate,

    This forum is for Unity Connect related issues (job posts, projects, bugs, etc).

    I'm pretty novice at Unity scripting and i'm not sure how to answer your issue...but,

    You should be able to define DelayTime = currentPeople.timeCount; as long as you reference, on the object that is running this script, the currentPeople object and it has some public variable called timeCount.

    In addition you wouldn't need to define timeCount here.