全站通知:
Camera code
刷
历
编
阅读
2023-08-26更新
最新编辑:TrimesS_
阅读:
更新日期:2023-08-26
最新编辑:TrimesS_
跳到导航
跳到搜索
简介
您可以通过引用全局客户端变量 Camera 来控制游戏摄像头。在客户端游戏循环的任何地方都可以访问和更改该变量。
您应在每帧调用的方法中编写摄像机代码,如 FrameSimulate。
示例
基础摄像头
/// <summary>
/// Get the View as Angles used in <see cref="BuildInput"/> and <see cref="FrameSimulate"/>
/// </summary>
[ClientInput] public Angles ViewAngles { get; set; }
/// <summary>
/// Allows to query the input and perform operations with it
/// </summary>
public override void BuildInput()
{
InputDirection = Input.AnalogMove;
var look = Input.AnalogLook;
var viewAngles = ViewAngles;
viewAngles += look;
ViewAngles = viewAngles.Normal;
}
/// <summary>
/// Called every frame on the client
/// </summary>
public override void FrameSimulate( IClient cl )
{
base.FrameSimulate( cl );
// Update rotation every frame, to keep things smooth
Camera.Rotation = ViewAngles.ToRotation();
Camera.Position = AimRay.Position;
Camera.FieldOfView = Game.Preferences.FieldOfView;
// Hide the player from the camera
Camera.FirstPersonViewer = this;
Camera.ZNear = 1f;
Camera.ZFar = 5000.0f;
}
正交相机
public override void FrameSimulate( IClient cl )
{
base.FrameSimulate( cl );
Camera.Main.Ortho = true;
Camera.Main.OrthoWidth = 100f;
Camera.Main.OrthoHeight = 100f;
}