- Home /
trouble opening URL from within game?
Hi Im in the process of making a game/learning environment for a school and the players need to be able to open subject areas in there main website from within the game.
Ive set up buttons which work fine using the Application.OpenURL technique but heres where im in trouble because i want them to be able to open those pages using there 3rd person characters within the game. Ive made teleporters with an game object with a box coliders attached and this JS attached
function OnTriggerEnter (other : Collider)
{
// Player touches teleporter!
if (other.GetComponent (ThirdPersonStatus))
{
other.GetComponent (ThirdPersonStatus).Application.OpenURL ("http://www.google.co.uk");
}
}
but im getting no response and this error
"NullReferenceException: Object reference not set to an instance of an object"
If anyone could help that would be great as unfortunately im not the JS wizard i think I am but am learning.
Many Thanks
Jules
Answer by DaveA · Jun 28, 2011 at 12:48 AM
Application.OpenURL is a 'standalone' call. It should not be attached to GetComponent or whatever
if (other.GetComponent (ThirdPersonStatus))
{
Application.OpenURL ("http://www.google.co.uk");
}
Thanks Dave sorted it now thanks to your help works like a dream.