| Blockland Forums > Modification Help |
| Function to determine direction player facing |
| (1/1) |
| darerd:
I need a function to figure out whether a player is facing north, east, south or west and then return 0, 1, 2 or 3. Also, if you could add in what this would be co-ordinate wise, that would be helpful too. Thanks |
| Port:
I am not that good at trigonometry and thus can't help you find the current direction, but I could reference what the different direction rotations are. 0North1 0 0 01East0 0 1 902South0 0 1 1803West0 0 -1 90 |
| Nexus:
this is from Client_BuildBot, so it is client sided code --- Code: --- function getplayerdirection() { if(isObject(%p = serverconnection.getcontrolobject())) { %va = getword(%p.getforwardvector(),0); %vb = getword(%p.getforwardvector(),1); if(mabs(%va) > mabs(%vb)) { if(%va > 0) return 0; else return 2; } else { if(%vb > 0) return 1; else return 3; } } else return 4; } --- End code --- 0 = east |
| Navigation |
| Message Index |