Log in to reply
 

Help in gtav scripting , camera



  • hi , I've been stuck on a problem , when i create the camera vision in gtav in visual studio , it shows me the vision but i cant return back to the player's camera . For better explanation ,I've create a camera vision Like this :

    World.Createcamera(postiion,something,fov) now this part its working well , but i cant return back to the player's camera and im stuck at this camera , I've tried almost everything and nothing works . If someone has an idea replay please



  • @avivr World.RenderingCamera = null;



  • @JohnFromGWN First thing i did and still doesn't work.



  • @avivr Post your code, this is SHVDN3

      public static Camera ScriptCamera { get; set; }
    
            public void ResetCamera(object sender, EventArgs e)
            {
                World.RenderingCamera = null;
                GTA.UI.Screen.ShowSubtitle("FOV:  " + GameplayCamera.FieldOfView + "  Zoom:  " + GameplayCamera.Zoom, 3000);
            }
    
            public void SetScriptCamera(object sender, EventArgs e)
            {
                CamPosition = PP.Position + new Vector3(4, 6, 0.0F);
                CamRotation = new Vector3(-90.0F, 0, 0.0F);
                CamFOV = 40.0F;
                ScriptCamera = World.CreateCamera(CamPosition, CamRotation, CamFOV);
                ScriptCamera.PointAt(PP);
                World.RenderingCamera = ScriptCamera;
    
            }


  • @JohnFromGWN sorry there is a delay between messages ,

    // Camera

                            newCamera = World.CreateCamera(new Vector3(756.3044f, -978.5467f, 30.81502f), new Vector3(0f, 0f, 0f), 70f); //, 102.3529
                            World.RenderingCamera = newCamera;
                            drivebyPed1.Task.DriveTo(drivebyCar1, new Vector3(721.6478f, -981.9289f, 24.09349f), 3f, 35f);
                            drivebyPed4.Task.DriveTo(drivebyCar2, new Vector3(720.1593f, -989.1492f, 24.10381f), 3f, 35f);
                            Wait(500);
                            newCamera.PointAt(drivebyCar1);
                            Wait(3000);
                            World.RenderingCamera = null;
                        }


  • @avivr your issue is with the wait statement. Im using 2 separate functions.



  • @JohnFromGWN right , but the wait is for waiting between the switch cams , i want the cam to display for a 3 sec and then switch up . what can i do ?





  • @avivr this worked for me. Might be a more elegant method, but does the job

    Wait(5000);
    ScriptCamera.Delete();
    World.RenderingCamera = null;



  • I have a very strange problem when using the CreateCamera() method.

    Every time I go back to GameplayCamera after using a new camera, I am unable to use the first person camera in vehicles, the only way to get back to normal, that is, "enabling" the first person camera from inside vehicles is using the DestroyAllCameras() method.

    Anyone having the same problem could tell me why this happens.



  • @Niziul Very few people, if any, are scripting the camera so you'll have to work it out yourself. What I can tell you, and you probably don't want to hear this, is that it does not work consistently. For example, at one point i had 4 camera setup and I switched seamlessly from 1 to 2 to 3 to 4 and then randomly it would stop at one of the 4 and not go back. I would do a reset no problem. Same issue, it would be stuck on one of the 4 and no longer allow the others. Exit the game, restart, problem gone.

    Having said that I've never had any issues after resetting to the game camera - all 4 POVs always work (the 3 third person and the first person). Same for the cinematic and the look behind camera views - no issues.



  • It's better to handle cameras using native functions directly tbh



  • @JustDancePC I normally use native functions because they have a tiny bit of documentation that's generally helpful. Why would they be better with the camera?



  • I just find it easier to use the natives for the camera than SHVDN's Camera class and never had any of the problems mentioned in this thread



  • @JohnFromGWN said in Help in gtav scripting , camera:

    @Niziul Very few people, if any, are scripting the camera so you'll have to work it out yourself. What I can tell you, and you probably don't want to hear this, is that it does not work consistently. For example, at one point i had 4 camera setup and I switched seamlessly from 1 to 2 to 3 to 4 and then randomly it would stop at one of the 4 and not go back. I would do a reset no problem. Same issue, it would be stuck on one of the 4 and no longer allow the others. Exit the game, restart, problem gone.

    Having said that I've never had any issues after resetting to the game camera - all 4 POVs always work (the 3 third person and the first person). Same for the cinematic and the look behind camera views - no issues.

    In fact, I ended up discovering the cause of this "problem". The mistake was entirely mine! I ended up calling the no update(Tick) method without a control variable, this caused it to generate a new camera every tick. And that kind of overloaded the method, I think. After adding the control variable, I no longer had to delete the camera in order for the gameplay camera to work properly.



  • @Niziul Ok, good. I never use the camera with ontick, never had reason to.



  • @JustDancePC try adding several cameras and keep switching back and forth. At some point game engine says, "that's enough". Btw, when I first started scripting, I was using vba.net with SHVDN2 and had similar issues. Now its SHVDN3 and C#.

    As for having this problem, it's only during testing. I would never switch back and forth dozens of time except for testing.



  • @JohnFromGWN In the case of constantly changing cameras, wouldn't it be easier to just have one camera and change its position?



  • @Niziul Absolutely. It depends what you're doing. If you have a camera attached to a ped, another to a car, one pointing at the player, etc...it might be simpler to just set them up for you scene as they do in real movies. It's really a question of choice. Right now I just have 2 cameras with code to change, x, y, z values, FOV, and to flip the camera back and forth. The other camera is attached to a ped which is set to follow the player. I do have a 3rd one attached to a vehicle - this is practical because you can just drive the car into a new position.



  • @JohnFromGWN Well, I've never had a reason to switch between cameras dozens of times, at least not in a short period of time.


Log in to reply
 

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