you mean in the 3rd person/main scene? I suspect they might raycast from the 3rd person gun, would also explain why they try to make sure that their 3rd person and 1st person animations and positions match up as well as possible(but also worth noting that theirs is a multiplayer game where it's 100% necessary to have that 3rd person model in there). Also I think the raycast checks might be happening server side in destiny, not 100% sure tho.

i meant getting a raycast from the camera to the lowered crosshairs' position my project wont be multiplayer

If the issue is with ray origin in perspective projection then maybe the solution is to do an orthogonal camera raycast? Not sure tho, I'd think there's a way to deal with it with perspective cameras just fine, probably just need to modify values before feeding into the raycast I guess. Mind, I haven't done the offset crosshairs thing for myself before, so I'm just guessing here.

https://docs.godotengine.org/en/stable/tutorials/physics/ray-casting.html#d-ray-casting-from-screen

In the example code given there I'd think it's the event.position that might have to be modified(added to or negated from by some value corresponding to crosshair offset).

Since I expect you to want to raycast into your game world I'm assuming you to be doing the raycasting from the camera rendering the game world and not your fps hands/gun rendering camera(assuming I even remember correctly that you had 2 different cameras, right?).

yes i need the correct position from the main camera to the crosshair to do the raycast. im not casting rays from my weapons. ill give it a go tommorow

heres' what i meant with the warped looking weapons(larger ones) at a high FOV of 70 i need that subviewport bug fixed to make em look good

i need that subviewport bug fixed to make em look good

Have you tried scaling the weapon model in a non-uniform manner (to squish it towards the camera origin)? This can simulate a similar look without the performance implications of using a secondary viewport.

@Calinou said:

i need that subviewport bug fixed to make em look good

Have you tried scaling the weapon model in a non-uniform manner (to squish it towards the camera origin)? This can simulate a similar look without the performance implications of using a secondary viewport.

yes ive tried scaling on z axis to fake shorter FOV but that only looks good when the weapon isnt moving alot. for example when the weapon rotates upwards in an animation the scaling begins to look very weird(squashed) and noticable. also, it doesnt fix weapon world clipping

Well I think it looks more like real life. When you film a movie, there is only 1 camera.

@cybereality said: Well I think it looks more like real life. When you film a movie, there is only 1 camera.

yes probably but i dont like that. its a game and weapon rendering is done in so many different ways in games, and almost always has a different FOV. also if u render a weapon at a lower FOV it doesnt take up so much space in the main view. one of the few good things unity introduced to the engine imo was having seperate render passes. so u could render the world and weapons in a different layer without a 2 camera setup

17 days later

so i lowered my reticle hud, i have no idea on how to get the correct position of the reticle to send a raycast to

Assuming that the camera aspect ratios are identical you could probably calculate a proportional offset match to raycast from the other camera?

edit: I'm not sure if fov difference might come into any play tho, since the reticle is part of the 2D hud I want to say it shouldn't but not having done this 2 camera thing myself I can't say for sure.

It's on the screen, so it should be a 2D coordinate. It would be the same code as if you were using the mouse position. Probably just some offset (like plus 200 pixels, but may vary depending on the screen resolution).

@Megalomaniak said: Assuming that the camera aspect ratios are identical you could probably calculate a proportional offset match to raycast from the other camera? yes aspect ratios are the same, but what about when the screen size changes?

@cybereality said: It's on the screen, so it should be a 2D coordinate. It would be the same code as if you were using the mouse position. Probably just some offset (like plus 200 pixels, but may vary depending on the screen resolution).

the resolution is 1920*1080. same question as to megalomaniak, what about when the resolution changes? for example when going fullscreen on a widescreen monitor? how to take that into account?

the reticle is currently at x 928 y 608 but that s not the center of the sprite, its 6464 wide ,upper left anchor in a resolution of 1920 1080

The code from the link above using the mouse position should work.

ok so how to obtain the correct event position?

const ray_length = 1000

func _input(event):
    if event is InputEventMouseButton and event.pressed and event.button_index == 1:
          var camera = $Camera
          var from = camera.project_ray_origin(event.position)
          var to = from + camera.project_ray_normal(event.position) * ray_length

No, not from the mouse. But all the same code, but with the screen position of the reticle instead of the mouse.

aye, in the example they use event.position because in the docs example they are using the mouse position. In your case you can probably create your own var crosshair_pos or whatever.

@DJM said: the reticle is currently at x 928 y 608 but that s not the center of the sprite, its 6464 wide ,upper left anchor in a resolution of 1920 1080

it's a texture rect right? you can parent it to a control node and name the control node as crosshair, the texture rect as crosshair_sprite, and now you can just get the crosshair position I guess.

If you set the texture rects pivot offset to it's center, you can also roll the crosshair when leaning/rotating the view around corners while taking cover or whatever.

@cybereality said: No, not from the mouse. But all the same code, but with the screen position of the reticle instead of the mouse. im an idiot. i dont know what to pass to the screen position heres my setup>