Oh helloes! Long time reader, first time poster.
I’m having a problem with static casting when I switched my project to an iOS environment. Didn’t think this at the time when I was coding with the windows version (works fine there), but I realize now that I should use #pragma strict.
The problem is, that when I try to call other gameobject script’s function I get compile errors like:
BCE0019: ‘isDead’ is not a member of ‘UnityEditor.PlayerSettings’.
I’m a bit puzzled and can’t find the solution
Here’s what I’ve got this far:
CameraStuff2.js:
#pragma strict
var pallo : GameObject;
var speed = 100;
private var playerConf : PlayerSettings;
function SwitchCollider()
{
if (playerConf.isDead() == 0)
{
if(pallo.GetComponent(Collider).GetType()==SphereCollider){
Destroy(pallo.GetComponent(Collider));
pallo.AddComponent("BoxCollider");
}
else
{
Destroy(pallo.GetComponent(Collider));
pallo.AddComponent("SphereCollider");
}
}
}
function Awake()
{
playerConf = GameObject.Find("Player").GetComponent("PlayerSettings") as PlayerSettings;
}
function Update ()
{
transform.position.x = pallo.transform.position.x;
transform.position.y = pallo.transform.position.y;
if (Input.GetKey (KeyCode.Space))
SwitchCollider();
if (Input.GetKey (KeyCode.LeftArrow))
transform.Rotate(Vector3.back * Time.deltaTime * speed);
if (Input.GetKey (KeyCode.RightArrow))
transform.Rotate(Vector3.forward * Time.deltaTime * speed);
}
PlayerSettings.js
#pragma strict
private var startLocation : Vector3;
private var playerDead;
public function setDead(x)
{
playerDead = x;
}
public function isDead()
{
return this.playerDead;
}
function Awake()
{
this.playerDead = 0;
this.startLocation = Vector3.zero;
}