First-Person Unit Control

Discussion in 'Mod Discussions' started by somdudewillson, March 17, 2015.

  1. somdudewillson

    somdudewillson Member

    Messages:
    64
    Likes Received:
    22
    I want to make a mod that introduces a unit that, when created, snaps the camera to a first-person view from said unit, and then allows for direct control via WASD and other keys?
  2. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    don't think that's possible
  3. somdudewillson

    somdudewillson Member

    Messages:
    64
    Likes Received:
    22
    Well, couldn't you just have keybindings that tell the unit to move relative to it's position?
  4. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    The API isn't that powerful sadly, for example:
    - there is no API to get the position of a unit
    - there is no API to set the camera position derp of course there is, I meant GET, sorry

    for other things, like giving a move command to a unit you have selected right now, workarounds exist, but what you are thinking of will require a lot of very deep digging to find a lot of workaronds then a bit of black magic and sorcery and then maybe you will find a hack to do it. Probably will require a little reading of process memory though.
    Last edited: March 17, 2015
  5. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    I'm pretty sure it's impossible to control a unit's movement with arrow keys. The camera part might be half-way possible since there is a way to snap the camera to a unit and ctrl-m changes camera angle.
  6. somdudewillson

    somdudewillson Member

    Messages:
    64
    Likes Received:
    22
    Well it seems that you can snap the camera to your Commander, so why couldn't you make a script/mod combination that snaps the camera to a different unit?
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    first person? Well then you can do that part.
    I am not saying it is totally impossible, but it will not be as easy as "call some ready made functions". Definitely FAR from easy, the part of controlling your unit is probably hardest.
    If you want to try here is a file I wrote to be able to give move commands in world coordinates to a unit: https://github.com/pamods/Minimap/blob/master/Minimap/ui/mods/minimap/unitcommands.js
    Then you probably will need a way to determine the position of the currently selected unit. The only way to get world coordinates is from alerts. I have so far not been successful in getting them for arbitrary units at arbitrary times. If you can figure something out please share it.
    Actually I do have one idea that may somewhat work: use the commander regeneration mod hack (a planet wide invisible explosion that deals positive damage to commanders) and combine it with another explosion that deal real damage. So you get no damage or regenration, but you might be able to have it generate regular "commander damaged" alerts that contain the location of your commander.
    zx0 likes this.

Share This Page