Solved Someone translate PortalGun from Python to C#

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Hello, someone would know to successfully translate this piece of code in Python Portalgun of Jakkee, translate to C #?

Thank you


Python:
hit = UnityEngine.Physics.RaycastAll(Player.PlayerClient.controllable.character.eyesRay)
                if len(hit) > 0:
                    hit[0].point.y += 2
                    hitlocation = hit[0].point
                    Player.SafeTeleportTo(hitlocation)
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Hello, someone would know to successfully translate this piece of code in Python Portalgun of Jakkee, translate to C #?

Thank you


Python:
hit = UnityEngine.Physics.RaycastAll(Player.PlayerClient.controllable.character.eyesRay)
                if len(hit) > 0:
                    hit[0].point.y += 2
                    hitlocation = hit[0].point
                    Player.SafeTeleportTo(hitlocation)
import UnityEngine
C#:
RaycastHit[] hit = Physics.RaycastAll(player.PlayerClient.controllable.character.eyesRay);
if (hit.Count() > 0)
{
    Vector3 hitlocation = hit[0].point;
    hitlocation.y += 2;
    player.SafeTeleportTo(hitlocation);
}
else
{
   //Did not find a location
}
 
  • Like
Reactions: salva

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
import UnityEngine
C#:
RaycastHit[] hit = Physics.RaycastAll(player.PlayerClient.controllable.character.eyesRay);
if (hit.Count() > 0)
{
    Vector3 hitlocation = hit[0].point;
    hitlocation.y += 2;
    player.SafeTeleportTo(hitlocation);
}
else
{
   //Did not find a location
}
thank you, thank you very much for your quick response .... I will test the code for what I want to do
 
  • Like
Reactions: Jakkee