OK, I want two (2) objects to push the same object. So, I copied Benji's code, and pasted the function with and copied the variables with 3's all over the place. Well, the first object that pushes still works, but the second doesn't work that well. The ball kinda slides off the object. I've searched all over my code for variables that might be used in the first function, but I can't figure it out. So here's my code (Not very commented):
(attached exe w/media)
sync on
sync rate 60
SET CAMERA RANGE 1,10000
` Help From UFO from TGC
` Benji*
` Load Ball :P
make object sphere 1,90
`scale object 1,750,750,750
load image "ball.bmp",1
texture object 1,1
`delete image 1
yrotate object 1,45
fix object pivot 1
`Make Collision
` Load Field
load object "field.3ds",2
load image "test.bmp",2
scale object 2,1500,1500,1800
texture object 2,2
` Make Player
make object cube 7,300
'scale object 7,30,60,30
make object cube 8,300
'scale object 8,60,60,30
` Goal
` Load the Frame of the Goal
load object "goal_frame.3ds",3
scale object 3,750,750,750
color object 3,rgb(255,255,255)
` Load the net of the Goal
load object "goal_net.3ds",4
scale object 4,750,750,750
load image "goal_net.bmp",4
set object transparency 4,1
texture object 4,4
position object 3,-1800,15,36
position object 4,-1800,15,36
` Copy the goals (5,6),(3,4)
clone object 5,3
clone object 6,4
`position other goals
position object 5,1790,15,47
position object 6,1790,15,47
`Turn them around
yrotate object 5,180
yrotate object 6,180
x#=object position x(3)
y#=object position y(3)
z#=object position z(3)
position camera 20,2775,-1515
point camera object position x(2),object position y(2),object position z(2)
rem Variabls
global bx#
global bz#
global a#
global a3#
global obj
`global pushobj
global bla
global bla3
global speed
global speed3
friction=4
speed=12
speed3=12
do
x2#=object position x(1)
z2#=object position z(1)
y2#=object position y(1)
text 0,0,"X : "+ str$(x2#)+" Z : "+ str$(z2#) + " Y : " + str$(y2#)
rem do function
moveobject(7,1,speed-2)
moveobject2(8,1,speed3-2)
rem movement
if upkey()=1
if bla=0
x#=newxvalue(x#,a#,speed)
z#=newzvalue(z#,a#,speed)
endif
endif
if downkey()=1
if bla=0
x#=newxvalue(x#,a#,speed*-1)
z#=newzvalue(z#,a#,speed*-1)
endif
endif
if leftkey()=1
a#=wrapvalue(a#-3)
endif
if rightkey()=1
a#=wrapvalue(a#+3)
endif
if keystate(157)=1
speed=20
else
speed=12
endif
if keystate(17)=1
if bla3=0
x3#=newxvalue(x3#,a3#,speed3)
z3#=newzvalue(z3#,a3#,speed3)
endif
endif
if keystate(31)=1
if bla3=0
x3#=newxvalue(x3#,a3#,speed3*-1)
z3#=newzvalue(z3#,a3#,speed3*-1)
endif
endif
if keystate(30)=1
a3#=wrapvalue(a3#-3)
endif
if keystate(32)=1
a3#=wrapvalue(a3#+3)
endif
if keystate(33)=1
speed3=20
else
speed3=12
endif
rem position and rotate pushobj in loop
position object 7,x#+200,y#,z#
yrotate object 7,a#
position object 8,x3#+200,y3#,z3#
yrotate object 8,a3#
if x2# > 1850 and z2# > -270 and z2# < 325
Text 100,100,"GOAAAAAAALLLL!!!"
endif
if x2# < -1840 and z2# > -270 and z2# < 346
Text 100,100,"GOAAAAAAALLLL!!!"
endif
sync
loop
function moveobject2(pushobj,obj,speed#)
`text 10,10,str$( pushobj)
if collbox=0
make object collision box pushobj,-10,-10,-10,10,10,10,1
make object collision box obj,-1,-10,-10,10,10,10,1
collbox=1
endif
if object collision (pushobj,obj)=1
bx#=newxvalue(bx#,object angle y(pushobj),speed#)
bz#=newzvalue(bz#,a#,speed#)
position object obj,bx#,by#,bz#
yrotate object obj,ba#
position object pushobj,bx#,by#,bz#
bla3=1
endif
if object collision (pushobj,obj)=0
if speed#>0
speed#=speed#-speed#
bx#=newxvalue(bx#,object angle y(pushobj),speed#)
bz#=newzvalue(bz#,a3#,speed#)
position object obj,bx#,by#,bz#
bla3=0
endif
endif
endfunction
function moveobject(pushobj,obj,speed#)
if collbox2=0
make object collision box pushobj,-10,-10,-10,10,10,10,1
make object collision box obj,-1,-10,-10,10,10,10,1
tmpspeed#=speed#
collbox2=1
endif
if object collision (pushobj,obj)=1
bx#=newxvalue(bx#,object angle y(pushobj),speed#)
bz#=newzvalue(bz#,a#,speed#)
position object obj,bx#,by#,bz#
yrotate object obj,ba#
position object pushobj,bx#,by#,bz#
once = 1
bla=1
endif
if object collision (pushobj,obj)=0
if speed#>0
speed#=speed#-speed#
bx#=newxvalue(bx#,object angle y(pushobj),speed#)
bz#=newzvalue(bz#,a#,speed#)
position object obj,bx#,by#,bz#
bla=0
endif
endif
endfunction
What happens is when the box using arrows, WASD( F) pushes the ball left, the ball slides up.
I would really appreciate the help from you guys. Thanks Everyone,
have a nice day!