- Home /
Getting my Actual IP? (not 120.0.0.1)
Sup Again Gang! tr4ying to implement getting my IP Automatically so the player doesn't have to look it up! thought it would be nifty to have in the game for people who don't know what IP is or find it to confronting just to play a game however i keep getting (120.0.0.1) (LOCAL IP) NOT MY ACUAL IP ADRESS! is their a way to find a players TRUE IP so they don't have to google search every time they want to play my game? trying to use: but i just get the old LOCAL HOST IP not my actual IP.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Networking;
public class AutoFill_IP : NetworkBehaviour {
// this script will Auto // Fill IP //
public string AutoFill_My_IP = "";
public Text IPAdress;
// Use this for initialization
void Start () {
AutoFill_My_IP = NetworkManager.singleton.networkAddress;
IPAdress.text = AutoFill_My_IP.ToString();
}
public void GetUIP_Button () {
AutoFill_My_IP = NetworkManager.singleton.networkAddress;
IPAdress.text = AutoFill_My_IP.ToString();
}
}
I guess you mean your public IP address? You usually need to hit an outside service that will return that for you.
There is an example here: http://stackoverflow.com/questions/3253701/get-public-external-ip-address
Answer by Sherlore · Aug 09, 2016 at 07:22 AM
Have you tried using "Network.player.ipAddress"?
I used it to show my IP to hold network game. But if you have multiple IP, It will give you "one" of your IP.
For code example: public InputField ip;
void Start ()
{
Debug.Log(Network.player.ipAddress);
ip.text = Network.player.ipAddress;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612090436im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A simple tutorial to send an email 1 Answer
How do I handle connection errors in a user friendly way? 0 Answers
Unity networking tutorial? 6 Answers