Creating a sprite that sits flush on a terrain
Blitz3D Forums/Blitz3D Beginners Area/Creating a sprite that sits flush on a terrain
| ||
Hi, As the title suggest, I have a terrain (of variable height), and I have a sprite that I want to act as a cursor that sits flush on the terrain (just a simple mesh) so I can move it around with the mouse etc. I am have no idea on how to make the sprite sit level with the terrain. I'm actually starting to think this isn't how you do it. Maybe I have to create a second texture that contains the sprite or something (but again, I don't know how to do this) Any help would be greatly appreciated. |
| ||
Are you talking about a sprite that "tilts" on the landscape - ie. if it is going up hill - it's base remains flat against the landscape (ie side of a hill) thus making it "tilt", ie. not stand up straight? I'm no expert, but the solution might be the way you are facing it - if it is a flat 2d sprite that is being steered, I am assuming you have the "wide side face" facing the camera - which I assume is harder to tilt than if you were "steering" the sprite longways across the landscape - perhaps you could intersect the sprite with another invisible one so that from above they look like this "+" then you could use one to reference the tilting on the landscape to offset the other. You best wait for expert advise from someone though as I have never tried this - it just sounds workable! |
| ||
Thanks for your reply, but I've figured out how to do it. Cheers |
| ||
Could you share your solution then? When the next guy searches the forum for this sort of thing, it would be cool if he could find an answer... |
| ||
You could do a line pick straight down and find the collision normal and align to vector or rotate to the angle. |
| ||
Thanks Ross, good suggestion to make simple shadows (I reccomend to use a 32Bit TGA for that kins of shadow: a simple black quad where the alphabyte holds the circular transparency fading. an other solution for people without a TGA Painting App could be to make the shadow negaitve(fade white in the center to black at the contours) and then invert the colour using writepixelfast, but leave the alphabyte unchanged) |
| ||
My solution, create a cube, scale it, paint a texture of an arrow on it, set the alpha level, and attach the cube to the parent entity. This is NOT my final solution, but I have more important things to work on my game at the moment. My final solution to this will pretty much be what Ross suggested. When the function is done, I will post it in the code archieves. I'm actually progressing pretty fast, so I will hopefully be able to implement it soon. Cheers |
| ||
Try this piece of code after you do a line pick nx# = PickedNX() ny# = PickedNY() nz# = PickedNZ() AlignToVector MySprite,nx,ny,nz,0 |