Code archives/User Input/Simple 3D Mouselook

This code has been declared by its author to be Public Domain code.

Download source code

Simple 3D Mouselook by slenkar2004
Easy mouselook for a 3D entity
Function Mouselook(entity)

my=MouseXSpeed()
mx=MouseYSpeed()
my=my*-1


TurnEntity entity,mx,my,0

End Function

Comments

Dabbede2004
Why not
my=-MouseXSpeed()
??


N2004
And how come no smoothness in the movement? It'd be very easy to add, just like this:

Global gMXSpeed#,gMYSpeed#,gMSpeed#

;; It's your job to reposition the mouse each frame if you so desire to.
Function SmoothTurn(Entity,PitchMax#=80)
	gMXSpeed = gMXSpeed*.9 - MouseXSpeed()*.2
	gMYSpeed = gMYSpeed*.9 + MouseYSpeed()*.2
	AX# = EntityPitch(Entity)
	AY# = EntityYaw(Entity)
	AX = AX + gMYSpeed
	AY = AY + gMXSpeed
	PitchMax = Abs(PitchMax)
	If Abs(AX) > PitchMax Then
		If AX < 0 Then
			AX = -PitchMax
		Else
			AX = PitchMax
		EndIf
	EndIf
	RotateEntity Entity, AX, AY, 0	;; ROLL == BAD
End Function


In any case, it's cool that you're sharing.


Code Archives Forum