Solved Someone translate PortalGun from Python to C#

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
621
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)
 
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
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