Log in to reply
 

Does anyone have info on scripting camera?



  • I've been using World.CreateCamera to script a camera, attaching it to a ped, player, or a vehicle's coordinates.

    I set the position, rotation, and FOV (normally about 50). Using methods PointAt and AttachTo.

    The equivalent of this, the Native, is:
    Cam CREATE_CAMERA_WITH_PARAMS(Hash camHash, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float fov, BOOL p8, Any p9) // 0x6ABFA3E16460F22D 0x0688BE9A b323

    Currently I've scripted 3 cameras in one scene, all fixed, one top view, 2 from the sides. Script allows me to move from one camera to the other - deleting and respawning cameras (haven't tried SET_CAM_ACTIVE yet).

    I assume if I want to move from fixed to moving cameras i need to use ontick? Is that correct?

    Does anyone know any other sources of information on camera scripts. Would like to take this further because I don't use the Rockstar editor nor any mods, prefer to do everything thru scripting.

    I've been using the Natives Database and link below from crosire, but would love to see some real world practical examples and code.

    https://github.com/crosire/scripthookvdotnet/blob/main/source/scripting_v2/GTA/Camera.cs



  • @JohnFromGWN Here is a demo of what i have so far, 4 subs each with their own camera, one sub to reset to the game play camera. All are fixed at this point.



  • Making progress. Still haven't figured out how to get camera to move properly. I've attached it to vehicle2 and assigned Camera 2. This shows movement but I need to figure out how to use ontick, i guess, so that position and rotation are updated with the movement. In passing I used to think the lack of documentation was a challenge, but now I realize it's actually helping me learn - the self-taught method is what I'm used to so this is the way to go without support.

    I just realized I need to build another script tool, like the one i wrote to attach a cup to a ped's hand, so i can fine tune the position and rotation coordinates and the FOV.



  • Here's an example of moving and rotating a camera, for a free cam mod: https://github.com/Starman0620/FreecamV



  • @Jitnaught Thank you. Will take a look. Gotta love the author's comment about 250 line in:

    "// Honestly I have no f******** idea what any of this does. I'm just copying it "

    Right now, I have about 3 lines of code for each camera. Hope I can pull something useful out of this. My application will be much simpler, not creating a mod, no user input, just a way to change the viewpoint but as the player or vehicle moves. Attachto and PointAt are the 2 methods I'm looking at right now, but I'm sure the solution is ontick given the position and rotation will constantly change as the camera moves.



  • @Jitnaught This script is pretty decent. I compiled it and ran it. Not perfect but much better than what I could do myself with my limited knowledge and experience. Going to play with it to see what i can learn. The vision hax are not necessary, those are easy to script, same for FOV, rolls etc. But the attach function, although hit or miss, is what i was looking for. The fact you can toggle the Hud on/off is great too.

    Thanks!


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.