Up and Down
Blitz3D Forums/Blitz3D Beginners Area/Up and Down
| ||
| Ok i can move across the terrain fine with terrianY but how can i move up and down a ramp mesh with the same effects as terrainY ?? (Like fall of the ramp and land on terrain/ move up and down ramp) |
| ||
| You would need to use the blitz collisions system (which can also be used with the terrain instead of terrainy.) It would look something like this:
myplayerentity=loadmesh("your player mesh or similar")
terrain=loadterrain("normal terrain loading stuff here")
ramp=loadmesh("your ramp or other obstacle")
entitytype myplayerentity,1
entitytype terrain,2
entitytype ramp,2
collisions 1,2,2,3 ;set sphere to polygon collision checking and only let it slide upwards
;obviously you'd need a camera and the like this is just really basic to get you started
repeat
;move your myplayerentity as normal with whatever commands you usually do
playeronground=false
For ColID=1 To CountCollisions(myplayerentity)
If EntityCollided(myplayerentity,2)=CollisionEntity(myplayerentity,ColID) Then
;player has collided with a static scene object, but what in particular....check if it is something beneath
;our feet by getting the direction from the player to the collision point
If CollisionY(myplayerentity,ColID)<EntityY(myplayerentity) Then PlayerOnGround=True
EndIf
Next
if playeronground=true then
playerverticalvelocity=0
else
accelerationduetogravity=some number, negative, and you'll have to play around with the value - start with small values at first eg -0.05 or similar
playerverticalvelocity=playerverticalvelocity+accelerationduetogravity
endif
translateentity myplayerentity,0,playerverticalvelocity,0
updateworld
renderworld
flip
until keydown(1)
end
|
| ||
| Thanx Matty, That solved it.. |