Move the model with the mouse
Blitz3D Forums/Blitz3D Beginners Area/Move the model with the mouse
| ||
I have a 3d model, and If the mouse hits a location on the terrain, then the model have to move to there. How to make something like this? (srry for my english :P ) |
| ||
http://www.blitzbasic.com/b3ddocs/command.php?name=CameraPick To find the location. Then place a pivot at that location Then point your entity towards it and move it in that direction taking into account surroundings and terrain height. |
| ||
Then place a pivot at that location Then point your entity towards it and move it in that direction taking into account surroundings and terrain height. howto make that, code plz |
| ||
if mousehit(1) then camerapick camera,mousex(),mousey() if pickedentity()<>0 then positionentity pivot,pickedx(),pickedy(),pickedz() endif endif pointentity yourentity,pivot moveentity yourentity,0,0,speed# positionentity yourentity,entityx(yourentity),terrainy(terrain,entityx(yourentity),0,entityz(yourentity)),entityz(yourentity) I'll let you flesh it out from there. |
| ||
okay but last question :P how to move the model to it because moveentity yourentity,0,0,speed# dont work :P and 1 more: pointentity yourentity,pivot i dont want that he points to pickedx() How to do this :P ok thanks |
| ||
You have to set 'speed#' to a non-zero positive value for it to work. If you want the unit to remain in an upright position, facing the pivot but not tilting then a better way would be to do this: aligntovector yourentity,entityx(pivot)-entityx(yourentity),0,entityz(pivot)-entityz(yourentity),3,1 |
| ||
aligntovector yourentity,entityx(pivot)-entityx(yourentity),0,entityz(pivot)-entityz(yourentity),3,1 i dont understand this : entityx(pivot)-entityx(yourentity what do u mean with that? |
| ||
the easiest way to keep your guy upright is to position the pivot at the same height as your player before pointing the player at the pivot. positionentity pivot, entityx(pivot),entityy(player),entityz(pivot) pointentity player,pivot |
| ||
positionentity pivot, entityx(pivot),entityy(player),entityz(pivot) pointentity player,pivot didn't u test this before, there is a bug in it when u click behind the player, then the model looks up. |
| ||
No I've not tested any of the code I've given you. You seem to assume people are going to write code for you without you trying anything yourself. Get off your backside and actually try something yourself. |
| ||
if pickedentity() = testentity then <do something> end if This code dont work why not |