#Free Looking Shotgun
1 messages · Page 1 of 1 (latest)
Make a neck and head then rotate both instead of the body
Consider a Subscription
Part 1 : https://www.youtube.com/watch?v=xIKErMgJ1Yk
Assets : https://github.com/lukky-nl/FPS-controller-assets
Kenney : https://www.kenney.nl/
Poly haven : https://polyhaven.com/hdris
This is part 2 of a 3 part fps contoller tutorial series!
i have a neck and head rotation
the shotgun needs to NOT rotate with the neck and head
oh you mean like make the shotgun part of the body?
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.
i changed the parent node
this part of the code is what copies the rotation and position so what would i change if i wanted it to for example be if !free_looking: copy transform but if free_looking: only copy position
global_transform.basis should return just rotation and scale
its global_rotation_degrees i think
Degrees will get it in degrees yeah, like 90 degrees.
would it just be global_rotate.basis
But I think object_a.global_transform.basis = object_b.global_transform.basis would also work
what would that do? stop rotation?
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
thats... the opposite of what i want no?
I thought you had a free look where you wanted it to turn or not depending on freelook enabled or disabled?
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
You could use if free_look == false and only run the rotation logic then.
That way it won't run while it's true.
still happens ;-;
here is the whole script incase something else may be fucking with the rotation, please take a look :)
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.
oh yeah i made that just now
y of head i believe
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
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
its in the player ;-;
Ah
if i set this to head.rotate.y it spins in circles
Ooof
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
Oh I see
hmph ill keep testing see if i can figure it out
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.
func _input runs every time there's input, so for mouse movement it will spam a lot