Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Diamond Casino Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA 6

      1. St Andrews Cathedral
    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
ikt

Camera range limited in FPV while playing animation

Recommended Posts

ikt
Posted (edited)

While I'm playing an animation, my camera range (how far I can look left/right) is severely limited, from 90 to driver side, 180 passenger/rear, to something like 30 either side. The range returns as soon as I stop the animation from playing.

 

// How the animation is started initially
        Timer t(500);

        STREAMING::REQUEST_ANIM_DICT(dict);
        while (!STREAMING::HAS_ANIM_DICT_LOADED(dict)) {
            if (t.Expired()) {
                UI::Notify(ERROR, fmt::format("Failed to load animation dictionary [{}}]", dict), false);
                break;
            }
            WAIT(0);
        }

        constexpr int flag = ANIM_FLAG_UPPERBODY | ANIM_FLAG_ENABLE_PLAYER_CONTROL;
        AI::TASK_PLAY_ANIM(g_playerPed, dict, name, -8.0f, 8.0f, -1, flag, 1.0f, 0, 0, 0);

// How the animation is sustained (time is set to a custom value)

        ENTITY::SET_ENTITY_ANIM_SPEED(g_playerPed, dict, name, 0.0f);
        ENTITY::SET_ENTITY_ANIM_CURRENT_TIME(g_playerPed, dict, name, time);

 

Has anyone run into a similar issue before?

 

Demo video:

 

Edited by ikt

Share this post


Link to post
Share on other sites
LeeC22
Posted (edited)

It's possible that in FPV, the camera is attached to the player's head at a relative offset and inherits the rotation of the player's head. The normal FPV animations might be an unrestricted set that allows the head to turn more than normal, whilst the TPV set will be restricted by rotation limits, because you can typically watch it externally. FPV might even hide the player's head and just apply a separate set of camera rotation limits to let you see all around.

 

If you switch to TPV and turn left or right, does the amount the head turns, look like it matches the limitations you are seeing from FPV using those animations?

 

Don't know if creating a custom camera and viewing through that, while the game thinks it is in FPV mode will reveal anything more, might be worth a quick try.

Edited by LeeC22

Share this post


Link to post
Share on other sites
ikt

Hmm, interesting thought. Tried the camera thing, but couldn't get the character to move around. It also looks like the character turn their heads slightly more (5 degrees or so) past what I can turn the camera in FPV.

 

Could be interesting to just plop in my own camera system (since looking left/right is half-broken with the gameplay camera anyway), but that'd further decrease compatibility with other camera mods.

Share this post


Link to post
Share on other sites
LeeC22
Posted (edited)

Just tried a couple of things to see if I could get an idea of what's going on.

 

To try and track the head direction, I attached a golf ball to the head bone at an offset of (0, .2f, 0) and because attached objects always track the bone they are attached to, that gave me a projected point just ahead of the player's head, meaning I could roughly track the direction the player was looking in. Using that confirmed that when you steer in FPV, the head doesn't turn.

 

I created the custom camera and switched to that when FPV mode was selected. The player just goes through the normal animations based on what I am seeing... however, the normal GameplayCamera isn't what is being used in FPV mode, it's a custom camera, which means none of the normal gameplay camera restrictions probably apply.

 

But that also that means there is already a custom camera in operation in that view mode anyway, so using your own shouldn't cause too much of a problem and you could make the switching optional in case anyone was using their own camera mods.

 

I've included the code for the test project, just in case anything in there is any use, like the object attaching stuff. I've found attaching golf balls to things proves quite useful at times, especially for bone tracking.

 

using System;
using System.Drawing;

using GTA;
using GTA.Math;
using GTA.Native;

namespace HeadTurnTest
{
    public class cHeadTurnTest : Script
    {
        private Ped PlayerPed;

        private Camera WatchMeCamera;
        private Prop HeadTracker;
        private bool CreatedTracker;

        public cHeadTurnTest()
        {
            Tick += onTick;
            Aborted += onAborted;

            Interval = 0;

            WatchMeCamera = World.CreateCamera(Vector3.Zero, Vector3.Zero, 40f);
        }

        private void onTick(object sender, EventArgs e)
        {
            if (Game.IsLoading) return;

            if (!CreatedTracker)
            {
                HeadTracker = World.CreateProp("prop_golf_ball", Vector3.Zero, false, false);
                CreatedTracker = true;
            }

            if (PlayerPed != Game.Player.Character)
            {
                PlayerPed = Game.Player.Character;
                HeadTracker.AttachTo(PlayerPed, PlayerPed.GetBoneIndex(Bone.SKEL_Head), new Vector3(0, .5f, 0), Vector3.Zero);
            }

            if (PlayerPed != null)
            {
                Vector3 headRootPos = PlayerPed.GetBoneCoord(Bone.SKEL_Head);
                Vector3 trackPos = HeadTracker.Position;
                Vector3 lineDir = (trackPos - headRootPos).Normalized;

                DrawLine(headRootPos, headRootPos + (lineDir * 2f), Color.Yellow);
                DrawLine(headRootPos, headRootPos + new Vector3(0, 0, 1f), Color.Magenta);
                DrawLine(trackPos, trackPos + new Vector3(0, 0, 1f), Color.LawnGreen);

                WatchMeCamera.Position = PlayerPed.GetOffsetInWorldCoords(new Vector3(0, 3f, 1f));
                WatchMeCamera.FieldOfView = 40f;
                WatchMeCamera.PointAt(PlayerPed, new Vector3(0, 0, 1f));

                //0 - Third Person Close
                //1 - Third Person Mid
                //2 - Third Person Far
                //4 - First Person

                if (Function.Call<int>(Hash.GET_FOLLOW_VEHICLE_CAM_VIEW_MODE) == 4)
                {
                    if (World.RenderingCamera != WatchMeCamera) World.RenderingCamera = WatchMeCamera;
                }
                else
                {
                    if (!GameplayCamera.IsRendering) World.RenderingCamera = null;
                }
            }
        }

        private void DrawLine(Vector3 position, Vector3 target, Color colour)
        {
            Function.Call(Hash.DRAW_LINE, position.X, position.Y, position.Z, target.X, target.Y, target.Z, colour.R, colour.G, colour.B, colour.A);
        }

        private void onAborted(object sender, EventArgs e)
        {
            if (!GameplayCamera.IsRendering) World.RenderingCamera = null;
            WatchMeCamera.Destroy();

            if (HeadTracker.IsAttached()) HeadTracker.Detach();
            HeadTracker.Delete();
        }
    }
}

Edit: Just realised I could have attached the golf ball with no offset to the head bone, then just drawn a line from the ball position + offset (0, 2f, 0) to show the direction the head was facing.

 

Both methods work but I usually take the long way round to get there, so it's no surprise I took this option first.

Edited by LeeC22
  • Like 1

Share this post


Link to post
Share on other sites
ikt
Posted (edited)

I've played around with "proper" animations (POV variant of steering animations), and it's still locked to the narrow range.

 

I'll try your golf-ball trick. See what the head bone does.

 

Update:

So apparently, the head only moves/rotates when one is in third person view. In first person view, the golf ball is static no matter if I play the animation and look around, or if I don't do anything and look around.

 

The head does move while steering, but it seems the camera is completely disconnected from it.

Edited by ikt
  • Like 1

Share this post


Link to post
Share on other sites
LeeC22

It's bizarre isn't it? I never use FPV mode but when I do little tests like this, I can see why people demand custom FPV modes. Every aspect of FPV mode, both in and out of cars just feels like a rushed hack. And as for the bonnet/hood cam... well that's just awful.

 

I have no doubts that if you created something that was an integrated component of your whole driving experience, you'd have something far superior to what people have right now. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.