#Isometric Controller Rotation with new input system

1 messages · Page 1 of 1 (latest)

main violet
#
    {
        Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit, maxDistance: 3000))
        {

            lookPos = hit.point;
        }
        Vector3 lookDir = lookPos - transform.position;
        lookDir.y = 0;

        Quaternion targetRotation = Quaternion.LookRotation(lookDir);
        Quaternion playerRotation = Quaternion.Slerp(transform.transform.rotation, targetRotation, playerControlData.rotationSpeed * Time.deltaTime);
        transform.rotation = playerRotation;

    }

the above code works. How ever i would like to set up the new input system actions to move my player. This is the new input system yes but i would like to use a action instead of calling Mouse.current.position.ReadValue();
I have tried using
playerControls.PlayerMovement.Look.performed += i => mousePos = i.ReadValue<Vector2>(); how ever this "works" but doesnt return correctly when plugged into the raycast.

violet sonnet
#

i.ReadValue in that context returns the mouse delta, not screen position

#

There's really no benefit in using events for this. You could do playerControls.PlayerMovement.Look.performed += i => mousePos = Mouse.current.position.ReadValue() but that would just add complexity for no reason

main violet
#

Ya, thats why im not using it. Im looking for how to use the Look in the InputMenu and not direct reading of Mouse.current.poition.ReadValue(); Ya i.ReadValue doesnt get screen poistion and thats where i want to know if i can somehow get screen poistion using i.something

violet sonnet
#

What would be the point? It would give the exact same value as Mouse.current.position.ReadValue()

main violet
#

Allowing integration of controller support without needing to virtualize mouse

violet sonnet
#

Controllers don't have a screen position

main violet
#

im aware. im mainly testing a theory i had

#

If i can find a way to get the values of the Look input that is set to non screen position and make it work as it was screen position values in theory i could do the same for controller

violet sonnet
#

The only thing that's tracked for controller sticks is the movement delta. You can do i => mousePos += i.ReadValue<Vector2>() to keep track of the screen position yourself

#

(and clamp it to screen resolution if you want to restrict it to the view the same way as a mouse cursor)

main violet
#

maybe i could do something with Mouse.current.WarpCursorPosition(inputManager.mousePos);

#

Ray ray = Camera.main.ScreenPointToRay(inputManager.mousePos); welp this worked

#

I guess unity was bugging out. As i tried this many time. Closed unity reoppened and boom working as it should have all along

main violet
#

Just like that controller is working perfect lol