Assistance on Rotate Quaternion & Eluer

Discuss modding questions and implementation details.
l3lessed
Posts: 1403
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Assistance on Rotate Quaternion & Eluer

Post by l3lessed »

This is the code in question.

Code: Select all

                        //defualt forward arccast setup for use.
                        Vector3 attackcast = GameManager.Instance.MainCamera.transform.forward;
                        //sets a Quaternion angle for adjusting arccast by calculating the angle of my forward look, multiplied to my up/down look and offset left by 20 degrees to center to raycast.
                        Quaternion objectRotation = Quaternion.LookRotation(GameManager.Instance.PlayerObject.transform.forward, GameManager.Instance.PlayerObject.transform.up);

                        //logic ladder to calculate actual arccast based on selected attack direction.
                        if (weaponState == WeaponStates.StrikeRight)
                        {
                            //lerps attack cast to move raycast from left to right.
                            attackcast = Vector3.Lerp(new Vector3(-110f, GameManager.Instance.PlayerObject.transform.position.y, GameManager.Instance.PlayerObject.transform.position.z), new Vector3(165f, GameManager.Instance.PlayerObject.transform.position.y, GameManager.Instance.PlayerObject.transform.position.z), percentagetime);
                            //rotates attack cast to forward position.
                            attackcast = objectRotation * attackcast;
                            //creates upwards rotation by cameras local upward rotation direction.
                            objectRotation = Quaternion.AngleAxis(GameManager.Instance.MainCamera.transform.localRotation.eulerAngles.x, GameManager.Instance.MainCamera.transform.right);
                            //applies upward rotation to forward attack cast.
                            attackcast = objectRotation * attackcast;
                        }
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1403
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Assistance on Rotate Quaternion & Eluer

Post by l3lessed »

Code: Select all

attackcast = Vector3.Lerp(new Vector3(attackcast.x - 110f, GameManager.Instance.MainCamera.transform.eulerAngles.y, GameManager.Instance.MainCamera.transform.position.z), new Vector3(attackcast.x + 165f, GameManager.Instance.MainCamera.transform.eulerAngles.y, GameManager.Instance.MainCamera.transform.position.z), percentagetime);
Even when I do this, it reproducers the same issue. I don't get it, as I'm hardcoding in the individual properties to ensure they are locked to the right object properties, but it still is happening. When I go to the top of the stairs in the first dungeon after the first room and attack, my raycast angle shifts upwards by 10 to 30 degrees or so just randomly.

Could this have to do something with the z cordinates? Would the height position of the player in the world some how affect this?
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
DunnyOfPenwick
Posts: 275
Joined: Wed Apr 14, 2021 1:58 am
Location: Southeast US

Re: Assistance on Rotate Quaternion & Eluer

Post by DunnyOfPenwick »

You said you get different results if you move to another location.

Does facing direction matter (north, south, east, west)? I would think that would matter more than position as that impacts global rotation values.

l3lessed
Posts: 1403
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Assistance on Rotate Quaternion & Eluer

Post by l3lessed »

That's the weird thing. I pulled up the camera object and checked the rotation values to ensure the values were the same when moving to the new spot. I have no idea conceptually where to even begin because the bug makes no sense to me. I do have an idea though, as the one thing I know is using the vector3 up/down values doesn't seem to have the same issue. Again, it is only when I rotate it using angles after the vector3 creation does this bug occur. I know because the down strike works fine using the vector3 up down for placement.

Maybe if I can translate the Euler angle into a proper vector3 up/down value, which I know can be done some how, it will fix this issue by decoupling the up down angle from Eulers. However, vector3 goes from -180 to 180 or -1 to 1 and Euler Angles are from 0 to 360 degrees. I have convert the rotation value to the proper vector3 value.

I'll keep messing with it when I have the time.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1403
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Assistance on Rotate Quaternion & Eluer

Post by l3lessed »

Think I got it.

Code: Select all

attackcast = Vector3.Lerp(new Vector3(-110f, GameManager.Instance.MainCamera.transform.rotation.z, GameManager.Instance.MainCamera.transform.position.z), new Vector3(165f, GameManager.Instance.MainCamera.transform.rotation.z, GameManager.Instance.MainCamera.transform.position.z), percentagetime);
It was simple actually. I needed to use the z rotation value. I can't explain it in any real technical terms, but when checking that property to ensure it was in vector3 radians and it shifted in up down yaw, it did. So it seems to have worked by bypassing angle use.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply