My problem here is that i want to move an object both horizontally and vertically without it slanting. In this code on the camera control i can get it to rotate horizontally and keep the object facing straight, but when I try to pitch it it rotates and falls off from being straight.
rem Control camera
a# = WrapValue(a#+MousemoveX()*0.2)
ya# = WrapValue(ya#+MousemoveY()*0.2)
`pitch object up 502,ya#
REMSTART
CREDITS TO
TDK_MAN(MatEdit Program)
Ali M(MatEdit refernce and explaination)
REMEND
`They said put it here
#include "LoadMatrix.dba"
`This too
Dim BigMatrix(600,600,1)
Dim StartLoc_X(1): Dim StartLoc_Z(1):Dim Info(2)
Dim TArrayX(1): Dim TArrayZ(1): Dim FKey(10,1)
Dim ColData(100): Dim ZoneData(100): Dim Tiles(500,500)
Dim OverTexture$(100): Dim OverName$(20): Dim ReplaceTex(100)
Dim MOffsetX(25): Dim MOffsetY(25)
Dim MWire(20): Dim MGhost(20): Dim Lock(20)
Dim MatX#(20): Dim MatY#(20): Dim MatZ#(20)
Dim MatWidth#(20): Dim MatHeight#(20)
Dim TilesX(20): Dim TilesZ(20)
Dim MatHi#(20): Dim MatLo#(20)
`Do basics
Sync On
Sync rate 60
Hide Mouse
Backdrop On
Color Backdrop 0
Autocam Off
load image "sky.bmp",100
rem Set screen to 800x600
set display mode 800,600,16
`Create a physical player
make object sphere 501,100
hide object 501
gosub createweapon
Rem The following line loads the matrix
Success=LoadMatrix("CHRISTMAS HILLS",1)
If Success=1
Set Camera Range 1.0, 900000.0
Hide Mouse
Rem Load the objects onto the matrix
open to read 1,"pform.ara"
nextplant:
s$=""
filepath$=""
read string 1, s$: objnum=val(s$)
read string 1, s$: filepath$=s$
read string 1, s$: xval=val(s$)
read string 1, s$: zval=val(s$)
read string 1, s$: orot=val(s$)
load object filepath$,objnum
scale object objnum,100000,100000,100000
position object objnum,xval,get ground height(1,xval,zval),zval
yrotate object objnum,orot
read string 1, s$
if s$ = "~" then goto nextplant
close file 1
Rem Load Monsters onto map
open to read 1,"mform.ara"
nextmonster:
s$=""
filepath$=""
read string 1, s$: objnum=val(s$)
read string 1, s$: filepath$=s$
read string 1, s$: xval=val(s$)
read string 1, s$: zval=val(s$)
read string 1, s$: orot=val(s$)
load object filepath$,objnum
scale object objnum,10000,10000,10000
position object objnum,xval,get ground height(1,xval,zval),zval
yrotate object objnum,orot
read string 1, s$
if s$ = "~" then goto nextmonster
rem Store monsters data
dim monsterhp(objnum,4)
close file 1
hgt = 100
chkcol=0
rem start loop
Do
rem Collision with polygons
`set object collision to polygons 501
rem Add setup
Texture Backdrop 100
sync
rem Control camera
a# = WrapValue(a#+MousemoveX()*0.2)
ya# = WrapValue(ya#+MousemoveY()*0.2)
[b] pitch object up 502,ya#[/b]
rem Control camera with arrow keys
if escapekey()=1 then end
if upkey()=1 then x#=newxvalue(x#,a#,50) : z#=newzvalue(z#,a#,50)
if controlkey()=1 then x#=newxvalue(x#,a#,200) : z#=newzvalue(z#,a#,200)
if downkey()=1 then x#=newxvalue(x#,a#,-50) : z#=newzvalue(z#,a#,-50)
if inkey$()="c" and chkcol=0 then chkcol=1: wait 100
if inkey$()="c" and chkcol=1 then chkcol=0: wait 100
if inkey$()="h" and object visible(501)=0 then show object 501: wait 100
if inkey$()="h" and object visible(501)=1 then hide object 501: wait 100
scroll backdrop a#,0
rem Update character & weapon
y#=get ground height(1,x#,z#)+hgt
position object 501,x#,y#,z#
position object 502,x#,y#,z#
yrotate object 501,a#
yrotate object 502,a#
rem Handle monsters
gosub controlmonsters
rem Handle sliding collision for player object with other objects
if chkcol=1
if object collision(501,0)>0
hgt = hgt + 25
else
if hgt>100 then hgt = hgt - 50
endif
endif
rem Position camera to the back of the character
cx#=newxvalue(x#,wrapvalue(a#+180),100)
cz#=newzvalue(z#,wrapvalue(a#+180),100)
cy#=y#+40.0
position camera cx#,cy#+ha#,cz#
rem Point camera at object
point camera x#,y#,z#
rem end loop
Loop
Endif
rem Subs
createweapon:
rem Load and modify weapon
load object "..\Props\weapons\AK47.3DS",502
scale object 502,30000,30000,30000
return
controlmonsters:
rem Search through and check if exist
for c = 201 to 300
if object exist(c)
rem Make objects face player
point object c,x#,y#,z#
endif
next c
return