How can I lock a players view to a target moving view?

Hey guys, I have been learning from these forums for a while so I figure it’s about time I ask a question myself :stuck_out_tongue: I am currently working with a small project, mostly for educational purposes, and though things have been going well until now, I am currently stumped.

The Problem:

I have a roller coaster set up, in which the player can board and unboard. There are some simple “ride” animations, and it all works quite well. However, I cannot get the ideal result of allowing the player to look around, while still maintaining position and rotation with the car.

So, pictures can be provided if needed, however it’s really quite simple/ugly :smiley: Essentially, there is a track, and a car which follows the track using a followPath Constraint in Blender. From here, I use an event tick to set the players position to the location of an arrow within the car.

This works, however the player does not rotate with the car -_- so I went and implemented a control rotation of the arrow onto the player controller, and of course, this locks the players view to that exact rotation every tick.

Solutions?

My best thoughts here are simply only checking every x seconds and situating the players view to the rotation of the car, OR it could be determined by a button press, but in all honesty I would very much like to have the player “follow” the car, rotational, as well as be allowed to look around from left to right on say a 90 degree angle.

Did play with angle limitations a bit, however that didn’t work, as the rotation was not being set, so the player would be stuck facing the back of the car when it turned :smiley:

Any help is greatly appreciated. Thank you for your time and effort!

I think you’ve got the right idea, but don’t lock the player’s rotation to the car, just let it ‘tend’ towards the car. That way you can let them look around, but when they stop trying to control rotation, their default will gracefully move back to following the direction of the car.

Many ways of doing this. One that spings to mind easily is let them look where they want, but use tick and an interp to move their gaze back to the car.

It’s a little hard to give you some code directly without knowing what nodes you’re using right now, but assuming you’re using SetControlRotation, it might look something like:

If you make a new level in a first person project and stuff that in the level BP, it will let you look around, but draw your view back to 0 on the Z axis given a chance.

It’s just a rough idea, there’s a couple of limitations:

  1. It takes the shortest route back to zero, which can make you spin.

  2. You may well be using all 3 axis for correcting the rotation. In which case you need to re-combine the pins and use a rinterpto ( or vinterpto for vector ).

Ahhh thank you! This looks like a solid option will try it out tonight and let you know how it goes. Looks exactly like what I was hoping for, thank you @ClockworkOcean

Works like a charm pal, bit bumpy set at 3, but I’m sure a little tinkering and I’ll be on my way! Owe you one :slight_smile: Upvoted at the least.

Are you ok to mark the question as answered? Many thanks :wink: