Jump to content

Abstract Camera movement


DigitalHax
 Share

Recommended Posts

Hey all,

 

I had a quick question about a technique used in quite a lot of games that I want to have a go at adding to mine. And that is abstract camera movement. Much like a person's head moving around to make it more realistic.

 

Now any suggestions on this? I have seen a few people around here achieve it. One person is franck22000, with his video in this post - http://www.leadwerks.com/werkspace/topic/4712-shadows-artifacts/

 

Any suggestions would be very helpful!

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

..this will give you nice walk camera feeling..i believe everything is self explanatory, but in any case, feel free to ask if there are issues..

 

..these are variables for control..

Global walking:Int = False 'are we walking or running

Global sp:Float =.08 'main walking speed (not connected with wobbling)

Global shoe_size:Float = 2.0 ' stepspeed for wobbling camera (eg. Higher Value=running, Smaller Value=walking , experiment yourself)

Global amplitude:Float

Global head_bang_X:Float = 0.09 ' amount of wobbling

Global head_bang_Y:Float = 0.07

Global move:TVec3 = Vec3(0)

Global myController:TController

Global camera:TCamera, camera_position:TVec3

Global footstep_needed:Int = False

 

..and these are functions you will use in your update cycle..

 

 

Function Move_Camera()

walking = False

If KeyDown(KEY_LEFT) Move = Vec3(-speed, 0, 0) ;walking = True

If KeyDown(KEY_RIGHT) Move = Vec3(speed, 0, 0) ;walking = True

If KeyDown(KEY_UP) Move = Vec3(0, 0, speed) ;walking = True

If KeyDown(KEY_DOWN) Move = Vec3(0, 0, -speed) ;walking = True

'here update your controller, if camera is attached to it

End Function

 

Function Wobble_Camera()

If walking amplitude = ((amplitude + shoe_size) Mod 360)

camera_position = Vec3((Cos(amplitude) * head_bang_X), (Sin(270 + (amplitude * 2)) * head_bang_Y), 0)

PositionEntity (camera, camera_position)

End Function

 

Function Play_Footstep_Sound()

If Sin(90 + (amplitude * 2)) < - 0.85

If footstep_needed

DrawText "Play a footstep sound here!", 50, 50

footstep_needed = False

EndIf

Else

footstep_needed = True

EndIf

End Function

 

 

..in your update, order of function calls should be :

 

Move_Camera()

Wobble_Camera()

Play_Footstep_Sound()

 

..I hope this helps...by adjusting some of the initial variables, you can have various motions..

 

Link to comment
Share on other sites

Ok, the only real thing I am not sure about is this line -

 

camera_position = Vec3((Cos(amplitude) * head_bang_X), (Sin(270 + (amplitude * 2)) * head_bang_Y), 0)

 

I don''t know how you would convert most of this line to cpp, especially with the Sin and Cos commands. Mostly because I am not sure what they do.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

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...