Question by
LettucePie · Nov 11, 2015 at 01:19 AM ·
vector3transform.positionmethods
Vector3 is not receiving enough arguments from a another script that gives out transform.position.
Trying to make a chess game. The floor tile script tells it's position to the currentplayer script. I was hoping to then set the position of the current player to the tiles position. I get an error stating it does not contain a constructor that takes 1 argument.
Floor TIle script
public class FloorTile : MonoBehaviour {
private CurrentPlayerActions playerMoving;
public int moveSelected = 0;
void Start ()
{
playerMoving = GameObject.FindObjectOfType(typeof(CurrentPlayerActions)) as CurrentPlayerActions;
}
void Update ()
{
if (playerMoving.cPlayermovingEnabled == 1)
{
Debug.Log("FLOOR TILE SEEKING INPUT");
}
}
void OnMouseDown()
{
if (playerMoving.cPlayermovingEnabled == 1)
{
Debug.Log("Tile Clicked");
playerMoving.MoveHere(this.transform.position);
}
}
public void visibleMoveTiles (int activated)
{
}
}
Current Player Script
public class CurrentPlayerActions : MonoBehaviour {
public int cPlayermovingEnabled = 0;
// Use this for initialization
void Start () {
}
public void enableMoving(int addOne)
{
addOne = cPlayermovingEnabled += 1;
if (cPlayermovingEnabled == 1)
{
Debug.Log("MovingEnabled");
}
}
void Update () {
}
public void MoveHere (Vector3 tilepos)
{
print(tilepos);
this.transform.position = new Vector3(tilepos);
}
}
Comment
Best Answer
Answer by Taorcb · Nov 11, 2015 at 02:21 AM
Don't create a new Vector3, just set transform.position to tilepos in your Current Player script
Thank you! I'm still amateur, so the help is very appreciated.