I’ve been going through the tutorials, getting a handle on how things work, and I ran into a problem I haven’t been able to solve.
I created a picking system using custom terrain that, like in the tutorial, left a red ball wherever I clicked. This worked flawlessly on my terrain until I implemented a CharacterControl for adding player physics.
I modified the Ray’s (used for picking) location and facing variables as such:
[java]Ray ray = new Ray(cam.getLocation(), cam.getDirection());[/java]
After: (Player is the CharacterControl)
[java]Ray ray = new Ray(player.getPhysicsLocation(), player.getViewDirection());[/java]
Since these changes, whenever I click, I’m told in console that there were 0 Collisions whether or not I’m facing the terrain.
I know this isn’t an issue with my picking code, as it worked flawlessly before. I’ve also tried using the original code using “cam” instead of “player”.Perhaps there’s a different method of doing this for CharacterControl?
It should also be noted that the player control also works flawlessly, so I don’t think anything with that is implemented incorrectly.
Thanks for your help!
Try drawing the ray using the Line class from the location in the direction with a fixed length. There is an example in the Math Video Tutorials somewhere. You can also try using the PhysicsRayCast
Thanks, wez. You helped me eliminate a few possibilities!
For those who are interested, I found the issue.
I created my terrain height map, textured my terrain, etc, and added it to the rootNode. In my code, I then continued on to manipulate the terrain to match my physics system. I then added it to rootNode again, under a different name. I didn’t run through the logic in my mind, but this renaming and modifying of the terrain seems to be the issue I was having. Both the basic terrain and the physics terrain were being added. The physics terrain likely lacked the ability to show up as a collision, and adding it a second time no doubt overwrote the first one.