#Free Looking Shotgun

1 messages · Page 1 of 1 (latest)

dusk kraken
#

Free Looking Shotgun

cosmic kettle
#

Make a neck and head then rotate both instead of the body

dusk kraken
#

the shotgun needs to NOT rotate with the neck and head

#

oh you mean like make the shotgun part of the body?

bold fable
#

I think I suggested just making it not parented to the rotating node yesterday. Or was it day before. Anyway yeah.
It's much easier to just copy the rotation of something (and use a boolean to enable/disable it) than fighting against the way node hierarchy automatically rotates child nodes.

dusk kraken
bold fable
#

global_transform.basis should return just rotation and scale

dusk kraken
#

its global_rotation_degrees i think

bold fable
#

Degrees will get it in degrees yeah, like 90 degrees.

dusk kraken
#

would it just be global_rotate.basis

bold fable
#

But I think object_a.global_transform.basis = object_b.global_transform.basis would also work

dusk kraken
#

what would that do? stop rotation?

bold fable
#

But I don't remember for 100% sure if that affects position too

#

It owuld copy rotation of b to a

#

If I remember right that is

dusk kraken
#

thats... the opposite of what i want no?

bold fable
#

I thought you had a free look where you wanted it to turn or not depending on freelook enabled or disabled?

dusk kraken
#

its this

#
if Input.is_action_pressed("free_look") or sliding:
        free_looking = true
        camera_3d.rotation.z = neck.rotation.y * free_looking_tilt
    else:
        free_looking = false
        neck.rotation.y = lerp(neck.rotation.y, 0.0, delta * lerp_speed)
        camera_3d.rotation.z = lerp(camera_3d.rotation.z, 0.0, delta * lerp_speed)
#

thats the free_look

#

but

#

i need it to NOT turn im free_looking is true

bold fable
#

You could use if free_look == false and only run the rotation logic then.
That way it won't run while it's true.

dusk kraken
#

still happens ;-;

#

here is the whole script incase something else may be fucking with the rotation, please take a look :)

bold fable
#

You have a boolean called rotate_gun and you are setting it true and false but nothing seems to actually use it?
Unless a different script is checking it.

#

Hmm so when freelooking is true, you rotate neck_y and head_x.
When it's false you rotate y (of whole model?) and also head_x.

I'm not entirely sure if the head_x part is meant to be outside the else or inside it.

To be honest I'm not entirely sure what's going on, either.
Have you tried messing with the rotations of the nodes in remote view while the game is running?
Maybe something is parented to something it shouldn't be parented to.

#

You could also try wrapping the head turn logic inside a function and temporarily ocmment out everything not related to it to have a more minimal test of it if it's overwhelming to read.

dusk kraken
#

because neck doesnt have a Y its only used for the free look and free look tilt factor

#

rotating the y of the whole model is nonsensical

bold fable
#

If the script is located in the character's head then that makes sense yeah.
Was just confused because you have head.rotate separately

#

'cos in this part

            rotate_gun = true
            rotate_y(deg_to_rad(-event.relative.x * mouse_sens))```

It's just saying ``rotate_y`` instead of ``head.rotate_y`` or ``neck.rotate_y`` so I was wondering haha
bold fable
#

Ah

dusk kraken
bold fable
#

Ooof

dusk kraken
#

wait a sec here

#

excuse the setup im live rn lol

#

there is background music in the game and shotgun sounds but i forgot to change the audio tabs my bad

bold fable
#

Oh I see

dusk kraken
#

ill show ya give me a sec

dusk kraken
bold fable
#

Yeah rotations can be a real pain.
When trying to debug anything all I can say is try a lot of print() to check all the booleans are what they should be.
Can also check them to check what everything is rotating to etc.

Sorry I couldn't be of much help.

dusk kraken
#

i think its this

#

it prints every frame instead of just once

bold fable
#

func _input runs every time there's input, so for mouse movement it will spam a lot