0
Answered

Rotate player and camera towards target (player looking to Camera Direction)

Lucas Romano 3 months ago in Game Creator updated by Marti (Lead Developer) 2 months ago 4

Hello,

I am trying to rotate the player and camera so that both look to an object (when opening a door and the player/camera is not looking to the door, for example). My player is always looking to the camera direction. I tried a lot of different things, like rotating both player and camera towards the target (using both rotate towards and look at), making player not controllable and disabling camera orbit input before also, but I could not make it work.

Please, is there an easy way of doing this? I mean, make both camera and player rotate together towards a target (player looking to Camera Direction)?

Unity version:
2019.4.0f1
Game Creator version:
1.1.9

So just saw this, and thought I would share what I did for similar mechanics. I set whatever it is I'm targeting (door, enemy etc) to a global variable GameObject, then I switch to a target motor, and set the target as the global variable. You can then edit the motor properties for the exact height that you want, offset etc. Also, your player should be pointing at the target (as it follows camera direction), but if you need some tweaking just set the character "look at" property too.

Hello, thanks for the reply. I tried that and I was able to make the camera and player look to the target, but I wasn't able to make it work smoothly. Also I was expecting an out of the box way of making this work with the adventure camera and player looking at camera direction without having to create another camera motor. Anyway, thanks for the help!

No worries! 


There may be an out of the box way, but this works quite nicely. I'm sure Marti or someone from Game Creator will reply with a cool way of doing it.

Switching camera motors isn't as bad as switching actual cameras like most of the other camera solutions (including Unity's out of the box solution).

If it's not very smooth, I would play with the transition times. 0.25 is too quick if you looking for a gradual change - so try 0.66 or even higher. 

Answered

In this case, I would treat this like a cinematic. When the character tries to open a door, make the character non-controllable first and setting the "Face direction" towards the player's movement (so it doesn't look where the camera aims at.

Now you can use a Change Camera to show the action from closer and use the move character to the door, so it correctly aligns with it. After playing the animation, return the player's face direction to the "camera direction", set the is controllable property to True again and change back to the previous camera motor.

This should give you a more cinematic look while focusing the camera on the door.