You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
sync on : Sync rate 0
autocam off : hide mouse
`Make a "player" object
make object cube 1,5
`Make an object to move around in front of us
make object sphere 2,1
`This object is basically for the camera to attach itself to. I tried just moving the camera directly rather than moving this object
`and then moving the camera around that, and it just... wouldnt run. It would compile, but then not do anything.
`Either way, this part isnt the problem
make object sphere 3,1
ghost object on 3
make matrix 1,1000,1000,50,50
MMx = Mousemovex() : MMy = Mousemovey()
X# = WrapValue(X# + MMx)
Y# = WrapValue(Y# + MMy)
`Rotate the player based on mouse movement
yrotate object 1,X#
`position that camera-pivot object at the players position, then move it up and back a bit.
position object 3,object position X(1),object position y(1),Object position Z(1)
move object 3,-10 `when I tried doing this by positioning the camera itself at the player position, and then
move object up 3,10 `just doing "move camera" and "move camera up" instead of using an object as a middle man, the
Yrotate object 3,Object angle y(1) `program just wouldnt DO anything. Itd complile file, but itd never open an actual application. I have no idea why
`position the camera
position camera object position X(3),object position y(3),Object position Z(3)
`rotate the camera based on mouse movement
yrotate camera X#
xrotate camera Y#
`use WASD keys to control player movement
if keystate(17) then move object 1,0.02
if keystate(31) then move object 1,-0.02
if keystate(30) then move object left 1,0.02
if keystate(32) then move object right 1,0.02
`Ok, so THIS is the part thats giving me trouble. as-is, the X ad Z work great, but I cant figure out how to get them to work
`TOGETHER with the Y. If you run the code, youll see the small sphere moves up and down on a straight line, rather than moving
`closer to the player on the X and Z as it moves up the Y, so as to maintain a constant total distance from the player.
`I have spent DAYS and tried a million different things, and I cant figure it out. In my defense, Im really not good with math
`and I honestly dont even truly actually KNOW what sine and cosine and all that even ARE. I managed to piece this together from
`code snippets and examples, so I dont know how to take it the next step further and integrate the Y with the X and Z.
position object 2,object position x(1) + sin(X#) * 30, sin(-Y#) * 30,object position z(1) + cos(X#) * 30
Login to post a reply