简体   繁体   English

旋转相机时旋转角色-3D游戏

[英]Rotating Character when I'm rotating camera - 3D game

I'm using MouseLook.cs to rotate the camera through a GameObject empty. 我正在使用MouseLook.cs通过GameObject空来旋转摄像机。 It works perfectly but I want to rotate also my character at the same speed as MouseX rotating. 它可以完美工作,但我也想以与MouseX旋转相同的速度旋转角色。 I tried to use THIS in my "movement character" script but It doesn't follow properly the rotating camera speed, I don't know why :S 我试图在我的“运动角色”脚本中使用THIS,但是它没有正确跟随旋转的相机速度,我不知道为什么:S

public float sensitivityX = 15f;   
transform.Rotate(0, Input.GetAxis("Mouse X")* sensitivityX, 0);

I searched on internet and tried various combinations but no one worked as I wanted. 我在互联网上搜索并尝试了各种组合,但没人能按我的意愿工作。

GameObject +带有MouseLook.cs的相机

I just want to do something like normal 3rd person Hack'n'Slash camera (like S4League, Trove, etc.). 我只想做像普通的第三人称Hack'n'Slash相机一样的事情(例如S4League,Trover等)。 And If anyone is asking If I followed the tutorial BurgZerg, I already did it and it isn't what I'm looking for. 如果有人问我是否遵循了BurgZerg教程,那么我已经做到了,这不是我想要的。

Thank you in advance who'll help me :) 在此先感谢您的帮助,:)

If you don't need to worry about other camera modes and your camera will always be behind your player then simply rotate your character instead of the camera with it attached to your character as a child positioned behind them. 如果您无需担心其他摄像头模式,并且您的摄像头将始终位于播放器后面,则只需旋转角色,而不是像将孩子附着在角色后面的那样将摄像头连接到角色上即可。

This way when your character rotates, the camera follows at the same speed of rotation as it is a child game-object. 这样,当您的角色旋转时,摄像机以与子游戏对象相同的旋转速度跟随。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM