Log in to reply
 

How do you get the camera to look behind you with native?



  • The player can change the gameplay camera view with the keyboard. Hitting the V key will cycle through 4 different views (Third Person Close, Third Person Mid, Third Person Far, and First Person).
    This can be done in a script with the following native:
    Native.Function.Call(Hash.SET_FOLLOW_VEHICLE_CAM_VIEW_MODE, 0) // for a vehicle
    Native.Function.Call(Hash.SET_FOLLOW_PED_CAM_VIEW_MODE, 0) //for a ped

    Similarly, Cinematic mode can be turned on and toggled off with the R key in a vehicle
    Native.Function.Call(Hash.SET_CINEMATIC_MODE_ACTIVE, True)
    Native.Function.Call(Hash.SET_CINEMATIC_MODE_ACTIVE, False)

    And finally, getting to the point and where I'm stuck, the C Key can allow a ped, walking or in a vehicle, to look behind.

    The native seems to be the following, and it does work, but there is a catch. The C key only allows you to look behind while it is held down.
    Native.Function.Call(Hash.SET_GAMEPLAY_CAM_RELATIVE_HEADING, 180.0F)

    So my question is, how can I script a look behind. Do I need to use the ontick? I'd like to mix up different game playcameras (along with scripted cameras too). So the driving would be scripted and during the drive the gameplay camera would do the corresponding functions associated had the player been mashing those 3 keys. I'm not concerned with scripted cameras at this point.

    IANAP (I am not a programmer, obviously).



  • SET_GAMEPLAY_CAM_RELATIVE_HEADING will work, but it won't work exactly the same as the C key. The C key still allows movement of the heading. Basically it just changes the origin heading, reverses the walking controls, and disables auto-centering. But for a scripting scene where you don't expect to move the mouse, this will work fine.

    public Test()
    {
    	Tick += Test_Tick;
    }
    
    private Test_Tick(object sender, EventArgs e)
    {
    	if (Game.IsKeyPressed(Keys.J)) //change to whatever you want to trigger the look-behind
    	{
    		Function.Call(Hash.SET_GAMEPLAY_CAM_RELATIVE_HEADING, 180f)
    	}
    }
    

    The camera will shake if you try to move it with the mouse.



  • @Jitnaught Thank you again for your help, it's very much appreciated. I'm starting to think my approach is wrong - using a keypressed event is not that much different from holding down the C key. Anyway I'm going to play with it. Other option would be to use a scripted camera in front of the vehicle. More things to try out!



  • @Jitnaught Ok, so I took your code, and added follow and cinematic functions, removed the key press, added some waits for those functions (not the look behind), set Menyoo to autodrive (to simulate a script as a quick test), and took my hands off the keyboard.

    Gave promising results, with the 3 functions (3rd/1st person, cinematic, and look behind). Would need to be fine tuned ofc, this is just a very rough no brainer demo, although the look behind kicked in at the right time.


Log in to reply
 

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