There's something strange with my weapon (Viewport, camera, mesh instance)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By R4mp3t

So, I’m making a sniper rifle in my game, and I wanna do a picture on picture scope for my rifle (This scope renders the world in a viewport). Everything is fine and it works, but, when I run my game the viewport displays in a same spot.
Is something strange because is like my scope camera isn’t from the player kinematic body.

Here’s a video about what happens to me.

I hope you can help me

(Srry for the bad fps)

Have you set the update more to always on the viewport .

magicalogic | 2023-01-03 10:31

Yes, I did that and the problem is still there. I think that the problem is in the node tree.

R4mp3t | 2023-01-03 17:34

:bust_in_silhouette: Reply From: AndyCampbell

I don’t have access to try a prototype right now, but I believe the problem is that the viewport object does not inherit from the spatial object so it does not actually track it’s position. This means that when your player object moves, the ScopeCamera object stays where it was. So, if you put a Camera as a child of the Viewport it’s location will not get updated.

One solution is to force updates to your ScopeCamera location using a script or using a RemoteTransform object. The RemoteTransform is super easy to use - just add that to your tree where you wan the camera to look from, then configure it to update the ScopeCamera object. That will take care of position and rotation etc

Dude, I love u. THANK YOU SO MUCH MY DUDE

R4mp3t | 2023-01-03 19:43

Cool! I hope that works out

AndyCampbell | 2023-01-03 20:05