tilting

Blitz3D Forums/Blitz3D Beginners Area/tilting

Agamer(Posted 2004) [#1]
Say when I go up a ramp I want it so the model tilts to be level with the ramp at the moment it jsut pushs forward can any one help


Stevie G(Posted 2004) [#2]
Assuming you're turning the model using turnentity you could try something like this (not tested I'm afraid but should work) ...

You may have to adjust some of the values but make sure the ramp and ground are pickable.

{code}
unused = LinePick ( EntityX(model,True),EntityY(model,True)+10,EntityZ(model,True),0,-20,0,.2 )
y#=PickedY()
TranslateEntity model,0,y-EntityY(model)+.1,0
nx#=PickedNX():ny#=PickedNY():nz#=PickedNZ()
AlignToVector model,nx,ny,nz,2,.25
{code/}


Agamer(Posted 2004) [#3]
umm I don't thnk this would work


Agamer(Posted 2004) [#4]
I think I'll try to exsplain better

Say I have a ramp like this
...
.....
........
...........

and I have a guy come into it

...
.....______________GUY
........______...............
...........___...............
and when he comes up it I want him to tilt
...
.....__..G
........__..U
...........__..Y

so I am not sure if that helps but there u go


Agamer(Posted 2004) [#5]
ok that really doesn't look like it helps here's a key


__ nothing
....board or ramp


Stevie G(Posted 2004) [#6]
Have you tried it? It works for me. If this is not what your after look at the car demo.

Try this (forgot how to put code in a box!!)....

Graphics3D 640,480,16,1

light=CreateLight()
gravity# = - 0.5

;guy
guy=CreateCube()
PositionMesh guy,0,1,0
Scaleentity guy,1,1,2
;camera
camera=CreateCamera(guy)
PositionEntity camera,0,5,-10
;plane
plane=CreatePlane()
EntityColor plane,0,0,255
EntityPickMode plane,2
EntityAlpha plane,.5
;ramp
ramp=CreateCube()
ScaleEntity ramp,4,.5,20
RotateEntity ramp,30,180,0
PositionEntity ramp,0,0,50
EntityColor ramp,255,0,0
EntityPickMode ramp,2

;main routine

While Not KeyDown(1)

TurnEntity guy,0,(KeyDown(203)-KeyDown(205))*5,0
MoveEntity guy,0,0,KeyDown(200)-KeyDown(208)*.5

unused = LinePick ( EntityX(guy),EntityY(guy)+1,EntityZ(guy),0,-200,0 )
y#=PickedY()
nx#=PickedNX()
ny#=PickedNY()
nz#=PickedNZ()
AlignToVector guy,nx,ny,nz,2,.25
TranslateEntity guy,0,gravity,0
If EntityY(guy) < y TranslateEntity guy,0,y-EntityY(guy),0

PointEntity camera,guy

RenderWorld()
Flip

Wend


Agamer(Posted 2004) [#7]
it did work sorry by any chance could you please exsplain it


Agamer(Posted 2004) [#8]
does any one know how to help


Ross C(Posted 2004) [#9]
StevieG's solution works fine. I used it for a car demo i was doing. It basicaly aligns the axis's of the car to the collision normal. You don't even need to use a pick command. This just uses collison normals

Use arrow keys to move block into the slope. It will align to the ramp

Graphics3D 800,600
SetBuffer BackBuffer()

light=CreateLight()
ground=CreatePlane()

camera=CreateCamera()

box=CreateCube()
PositionEntity box,0,2,0
PositionEntity camera,0,6,-20
RotateEntity ground,0,0,30
EntityType ground,2
EntityType box,1
Collisions 1,2,2,2


While Not KeyHit(1)

If KeyDown(200) Then MoveEntity box,0,0.1,0
If KeyDown(208) Then MoveEntity box,0,-0.1,0
If KeyDown(205) Then MoveEntity box,0.1,0,0
If KeyDown(203) Then MoveEntity box,-0.1,0,0
If KeyDown(2) Then TranslateEntity box,0,0.1,0
If EntityCollided(box,2) Then
	AlignToVector box,CollisionNX(box,1),CollisionNY(box,1),CollisionNZ(box,1),2
	temp=CollisionNZ(box,1)
	col=1
Else
	col=0
End If



UpdateWorld()
RenderWorld()

Text 0,0,"normalx="+temp
Flip
Wend
End



Agamer(Posted 2004) [#10]
THx for the help ross it works now!