| Blockland Forums > Modification Help |
| Activate different parts of a brick? |
| << < (4/4) |
| PhantOS:
Same principle. You get the hit point of your eye vector and check if it's transform is within a certain area |
| Platypi:
As far as determining which surface you are looking at, you can use raycasts. I did something like this in Trench Digging Plus. Here's a succinct version of what I did in my code --- Code: ---%eyePoint = %client.player.getEyePoint(); %eyeVector = %client.player.getEyeVector(); %pos = vectorAdd(%eyePoint, 100); // You will probably want to tweak the range here; 100 is probably too big for your purposes %ray = containerRayCast(%eyePoint, %pos, $TypeMasks::FxBrickObjectType); %brick = firstWord(%ray); %normal = normalFromRayCast(%ray); --- End code --- That %normal will tell you what surface the player is looking at. A normal of "0 0 1" indicates the top surface, "0 0 -1" the bottom, and "0 1 0", "1 0 0", "0 -1 0", "-1 0 0" the north, east, south and west surfaces, respectively (I am not sure if these are conventionally considered north, south, east, and west, but it is how I refer to them). One thing to note is that the normal vectors are not always perfect. That is, you might get a vector more like "6.172444e-123 0 1" instead of "0 0 1". If you're just dealing with basic normal surfaces (no inclined or oblique surfaces), then you can just round each coordinate value. Are you trying to create event triggers, like onActivateTop or onActivateNorth, etc.? |
| xS K I D z:
--- Quote from: Platypi on February 28, 2018, 07:43:39 PM ---Are you trying to create event triggers, like onActivateTop or onActivateNorth, etc.? --- End quote --- Thanks for the help:) And about the events, possibly. At first I wanted it to do it automatically but now I think it might be better the other way |
| Mocha:
You cannot assume normals will be some variant or close variant of 0 0 1/0 1 0/1 0 0 as it does return the normal of the surface hit. For example, if your raycast hits a ramp brick or static shape, it will return the normal of the face hit |
| Platypi:
--- Quote from: Mocha on March 09, 2018, 02:12:36 PM ---You cannot assume normals will be some variant or close variant of 0 0 1/0 1 0/1 0 0 as it does return the normal of the surface hit. For example, if your raycast hits a ramp brick or static shape, it will return the normal of the face hit --- End quote --- --- Quote from: Platypi on February 28, 2018, 07:43:39 PM ---If you're just dealing with basic normal surfaces (no inclined or oblique surfaces), then you can just round each coordinate value. --- End quote --- If you're only creating triggers for normal surfaces, rounding within 0.001 (or something similar) should provide enough accuracy. Normals that fall outside that bound can be considered inclined or oblique, and simply be ignored. I'm not sure how you could create event triggers for inclined or oblique surfaces without creating an ungodly number of them. |
| Navigation |
| Message Index |
| Previous page |