Quote: "whenever i walk i just slide around"
I've been suffering with this recently but then it has been snowing quite heavily these past few days
Being serious for a minute, yes, you can use sine or cosine as a starting point but you need to play around with the values to get something that looks right.
This is a pretty basic implementation of what you're thinking of:
sync on
sync rate 65
make matrix 1, 1000,1000,10,10
`constants used to control the position of the camera
cam_height = 10 :`this is the nominal y position of the camera
bob_speed = 15 :`this controls how fast the camera bobs up and down, adjust to suit
bob_distance = 5 :`this controls how much the camera bobs up and down when moving, adjust to suit
do
if upkey() = 1
inc zpos, 5 :`move camera foward
inc theta, bob_speed :`this value is used to bob the camera up and down
endif
if downkey() = 1
inc zpos, -5 :`move the camera backwards
inc theta, bob_speed*-1 :`this value is used to bob the camera up and down
endif
`this bobs the camera based on value of theta
ypos = bob_distance*sin(theta) + cam_height
`position and point the camera
position camera 500, ypos, zpos
point camera 500, ypos, zpos + 100
text 1,1, "Use up and down arrow keys to move camera foward and back"
sync
loop
As I said, this is pretty basic and there might be better ways of doing this but I hope it helps.