Jump to content

First First Person Camera


fumanshoo
 Share

Recommended Posts

I know that this is a really noob question, but I am extremely new to programming in general and I've been pretty closely following Jorn theunissen's videos, specifically this one...

and after following the tutorial, everything worked until I "attached" the 1st person camera. So far, I've got the camera where it's supposed to be this far into the tutorial, but it wont stop spinning to the left. If anyone would be willing to explain why this is happening and how I can fix it, it would be much appreciated.

 

errr, I don't think my attachment properly uploaded... here's what I've written...

 

 

require("Scripts/constants/engine_const")

 

COLLISION_CHARACTER=1

 

RegisterAbstractPath("")

 

Graphics(800,600)

 

fw = CreateFramework()

 

camera = fw.main.camera

camera:SetPosition(Vec3(3,2,-10))

 

light = CreateDirectionalLight()

light:SetRotation(Vec3(45,45,0))

 

scene = LoadModel("abstract::GeneralVisualizationoftheSlums.gmf")

scene:SetCollisionType(1)

scene:SetRotation(Vec3(0,90,0))

 

controller = CreateController(1.8,0.3,0.5 , 45)

controller:SetMass(10)

controller:SetCollisionType(COLLISION_CHARACTER)

controller:SetPosition(camera)

controller:Move(Vec3(0,1,0))

 

DebugPhysics(1)

 

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)

camRotation = Vec3(0)

dx = 0.0

dy = 0.0

 

strafe = 0

move = 0

 

while KeyHit(KEY_ESCAPE)==0 do

 

gx=Curve(MouseX()- GraphicsWidth()/2,gx,3.0/AppSpeed())

gy=Curve(MouseY()- GraphicsWidth()/2,gx,3.0/AppSpeed())

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)

camRotation.x = camRotation.x + gx / 8

camRotation.y = camRotation.y - gy / 8

camera:SetRotation(Vec3(camRotation.x,camRotation.y,1))

 

move = Curve( (KeyDown(KEY_W)-KeyDown(KEY_S)) * 5, move , 3 )

strafe = Curve( (KeyDown(KEY_D)-KeyDown(KEY_A)) * 5, strafe , 3 )

 

controller:Update(0, move, strafe, jump, 25 , 10)

 

fw:Update()

 

camera:SetPosition(Vec3( controller.position.x, controller.position.y, controller.position.z ))

 

fw:Render()

 

Flip(0)

end

Link to comment
Share on other sites

It made me look at it outside of the editor heh. It was amazing how instantly it came to me though! ... although there are still a few tweaks I have to make to perfect this. For example, the camera moves at an angle instead of normally but i'm sure i'll figure it out.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...