DigitalHax Posted May 18, 2012 Share Posted May 18, 2012 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! Quote 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 More sharing options...
Naughty Alien Posted May 18, 2012 Share Posted May 18, 2012 ..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.. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 18, 2012 Author Share Posted May 18, 2012 Aha thanks. I'll convert this to cpp and see if it works. Quote 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 More sharing options...
dennis Posted May 19, 2012 Share Posted May 19, 2012 Headbobbing Quote Link to comment Share on other sites More sharing options...
Naughty Alien Posted May 19, 2012 Share Posted May 19, 2012 hahahaah Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 19, 2012 Author Share Posted May 19, 2012 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. Quote 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 More sharing options...
Rick Posted May 19, 2012 Share Posted May 19, 2012 #include <math> and you should have a cos() and sin() function. Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 19, 2012 Author Share Posted May 19, 2012 Ok thanks Quote 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 More sharing options...
Recommended Posts
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.