Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Question on Basic Drone Follower Script

Discussion in 'Programming Questions and Suggestions' started by Abyzmi, Mar 25, 2019.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Abyzmi Trainee Engineer

    Messages:
    66
    Hey friends,

    I have this script that I partially created using the drone AI that spawn over pirate bases in-game.


    List<IMyTerminalBlock> list = new List<IMyTerminalBlock>();
    public void Main(string argument, UpdateType updateSource)
    {
    GridTerminalSystem.GetBlocksOfType<IMyRemoteControl>(list);
    var remote = list[0] as IMyRemoteControl;
    remote.ClearWaypoints();
    Vector3D player = new Vector3D(0,0,0);
    bool success = remote.GetNearestPlayer(out player);
    if(success){
    remote.AddWaypoint(player, "Player");
    }
    remote.SetAutoPilotEnabled(true);
    }


    My problem here is that the bool success never equals true, and therefor never updates the waypoints in the remote block.

    I assume that me, being a player, would trigger the remote block's nearest player attribute.

    Any suggested fixes for this?

    Also, is there a method for the remote block that says to get the nearest *enemy* player instead of just the nearest player?
     
  2. Wicorel Senior Engineer

    Messages:
    1,239
    GetNearestPlayer is only available for scripts on blocks owned by the PIRATE faction.

    You'll need to use other methods. such as a sensor. to get the location of a player
     
  3. Abyzmi Trainee Engineer

    Messages:
    66
    Okay. Thanks.

    Disappointing but I suppose that makes sense. Would be pretty OP if everyone had drones that went straight over to their enemy.
     
Thread Status:
This last post in this thread was made more than 31 days old.