SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
85 stars 18 forks source link

player look check not working (Raycast i was told its called) #3542

Closed Akulation closed 1 year ago

Akulation commented 1 year ago

In my server any command/event/whatever that uses the function of a player looking at a barricade/player/vehicle stopped working. This is for a couple of rocketmod plugins aswell as uscripts.

The main one that is happening is for a plugin that allows players to revive another player by using surrender and looking at the knocked down player.

GazziFX commented 1 year ago

All of my plugins with raycast works fine

Akulation commented 1 year ago

okay, to update on this, the barricades/structures are working for raycast. the vehicles and players are not working though.

GazziFX commented 1 year ago

What exactly code fails?

GazziFX commented 1 year ago

This is how I use raycasts in my plugins

var aim = sp.player.look.aim;

if (Physics.Raycast(aim.position, aim.forward, out var hit, cfg.Distance, RayMasks.DAMAGE_PHYSICS))
{
    var col = hit.collider;
    if (col != null)
    {
        var t = col.transform;
        if (col.CompareTag("Structure"))
        {
            t = DamageTool.getStructureRootTransform(t);
            var drop = StructureManager.FindStructureByRootTransform(t);
            if (drop != null)
            {
            }
        }
        else if (col.CompareTag("Barricade"))
        {
            t = DamageTool.getBarricadeRootTransform(t);
            var drop = BarricadeManager.FindBarricadeByRootTransform(t);
            if (drop != null)
            {
            }
        }
        else if (col.CompareTag("Vehicle"))
        {
            var vehicle = DamageTool.getVehicle(t);
            if (vehicle != null)
            {
            }
        }
    }
}
Akulation commented 1 year ago

im not sure, i dont make my own plugins for rocketmod. the plugins are used by many people and seem to work for everyone, i was told by the plugin developer to ask here for help.