I am trying to write a simple script for rotating the camera with the mouse without any buttons, Can anybody help me? Better solution or fixing my script.

It works but the direction is acting weird. Also can you help me with the Y axes as well please!

[SCRIPT]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using WaveEngine.Common.Math;

using WaveEngine.Framework;

using WaveEngine.Framework.Graphics;

using System.Windows.Forms;

using WaveEngine.Framework.Services;

using WaveEngine.Components.Transitions;

namespace RELOCATIONProject.Behaviors

{

class InputBehavior : Behavior

{

[RequiredComponent]

public Camera3D Camera;

Vector3 camDir;

double dir;

float turnSpeed;

public InputBehavior(float CamSpeed)

{

turnSpeed = CamSpeed;

}

protected override void Update(TimeSpan gameTime)

{

if (camDir == null)

{

camDir = new Vector3();

camDir = Camera.LookAt;

dir = 0;

}

if (WaveServices.Input.MouseState.X < 510)

{

dir-= turnSpeed;

}else

if (WaveServices.Input.MouseState.X > 514)

{

dir += turnSpeed;

}

else

{

dir = 0;

}

if (dir > 360)

{

dir -= 360;

}

if (dir < 0)

{

dir+= 360;

}

System.Drawing.Point P = new System.Drawing.Point();

P.X = 512;

P.Y = 384;

Cursor.Position = P;

float X = camDir.X;

float Y = camDir.Y;

float Z = camDir.Z;

X = LengthDirX(dir, 500, Z, Camera.Position);

Z = LengthDirZ(dir, 500, Z, Camera.Position);

camDir.X = X;

camDir.Z = Z;

Camera.LookAt = camDir;

}

public float LengthDirX(double Direction, float x, float y, Vector3 Position){

float _x = x;

float _y = y;

x = Position.X + (float)(_x * System.Math.Cos(Direction) - _y * System.Math.Sin(Direction));

y = Position.Z + (float)(_x * System.Math.Sin(Direction) + _y * System.Math.Cos(Direction));

return x;

}

public float LengthDirZ(double Direction, float x, float y, Vector3 Position)

{

float _x = x;

float _y = y;

x = Position.X + (float)(_x * System.Math.Cos(Direction) - _y * System.Math.Sin(Direction));

y = Position.Z + (float)(_x * System.Math.Sin(Direction) + _y * System.Math.Cos(Direction));

return y;

}

}

}

[/SCRIPT]

It works but the direction is acting weird. Also can you help me with the Y axes as well please!

[SCRIPT]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using WaveEngine.Common.Math;

using WaveEngine.Framework;

using WaveEngine.Framework.Graphics;

using System.Windows.Forms;

using WaveEngine.Framework.Services;

using WaveEngine.Components.Transitions;

namespace RELOCATIONProject.Behaviors

{

class InputBehavior : Behavior

{

[RequiredComponent]

public Camera3D Camera;

Vector3 camDir;

double dir;

float turnSpeed;

public InputBehavior(float CamSpeed)

{

turnSpeed = CamSpeed;

}

protected override void Update(TimeSpan gameTime)

{

if (camDir == null)

{

camDir = new Vector3();

camDir = Camera.LookAt;

dir = 0;

}

if (WaveServices.Input.MouseState.X < 510)

{

dir-= turnSpeed;

}else

if (WaveServices.Input.MouseState.X > 514)

{

dir += turnSpeed;

}

else

{

dir = 0;

}

if (dir > 360)

{

dir -= 360;

}

if (dir < 0)

{

dir+= 360;

}

System.Drawing.Point P = new System.Drawing.Point();

P.X = 512;

P.Y = 384;

Cursor.Position = P;

float X = camDir.X;

float Y = camDir.Y;

float Z = camDir.Z;

X = LengthDirX(dir, 500, Z, Camera.Position);

Z = LengthDirZ(dir, 500, Z, Camera.Position);

camDir.X = X;

camDir.Z = Z;

Camera.LookAt = camDir;

}

public float LengthDirX(double Direction, float x, float y, Vector3 Position){

float _x = x;

float _y = y;

x = Position.X + (float)(_x * System.Math.Cos(Direction) - _y * System.Math.Sin(Direction));

y = Position.Z + (float)(_x * System.Math.Sin(Direction) + _y * System.Math.Cos(Direction));

return x;

}

public float LengthDirZ(double Direction, float x, float y, Vector3 Position)

{

float _x = x;

float _y = y;

x = Position.X + (float)(_x * System.Math.Cos(Direction) - _y * System.Math.Sin(Direction));

y = Position.Z + (float)(_x * System.Math.Sin(Direction) + _y * System.Math.Cos(Direction));

return y;

}

}

}

[/SCRIPT]

## Comment