My ChaseCamera Collision Problem

Hey everyone, I’ve been working on a chasecamera ray casting situation all day. I have a couple of issues.
This is my code for the ray casting and collision checks on the chasecamera and its moving object:

      CollisionResults results = new CollisionResults();
      Ray ray = new Ray(cam.getLocation(), cam.getDirection());
      
      teaGeom.collideWith(ray, results);
    
  
      if(results.size()>0){
          CollisionResult closest = results.getClosestCollision();
          chaseCam.getMinDistance();
      }

I’m using the TestChaseCamera tutorial but I thought something might go through if I worked on the simpleUpdate method with CollisionResults and Ray. I keep getting the feeling that the camera isn’t meant for collision detection like the Zelda one is.

You understand that this line of code isn’t really doing anything, right?

I know. I figured it wasn’t. Why is that though? I’m starting to think these ray castings can only be done with cameranode

We aren’t equipped to troubleshoot your feelings. Tell us more about the behavior of the software that’s causing those feelings.

1 Like

This is a method that retrieves a value. It doesn’t do any work. You aren’t even catching the value and doing anything with it.

You aren’t doing anything with “closest”, either.

The code posted is a whole lot of “doing nothing”.

Learning Java and game programming at the same time is very difficult.

Excuse me while I go cry on my keyboard :sob:
Sorry about that guys. I’ll keep trying.

would it seem better if I used:
if(results.size()>0){
CollisionResult closest = results.getClosestCollision();
closest.setContactPoint(teaGeom.getLocalTranslation())

}

No. Now you are modifying the results of the collection test.

Trying random things and hoping they work without understanding what you are doing… is going to take a long time. Millennia.

I kind of feel like if you wrote out what you are trying to do, step by step, in english… it would in no way resemble the code you are randomly trying to make work.

That’s pretty critical.

Are you trying to do 3rd person with mouse picking?

yes

Is the raycast intended to calculate how far the camera should be from the player’s position?

This BaseAppState of the jme3AI tutorial uses 3rd person with picking. Uses the Sinbad.mesh.xml located in the test-data library.

Edit:
Its based off these wiki tutorials,
https://jmonkeyengine.github.io/wiki/jme3/advanced/making_the_camera_follow_a_character.html
https://jmonkeyengine.github.io/wiki/jme3/advanced/camera.html
https://jmonkeyengine.github.io/wiki/jme3/beginner/hello_picking.html
https://jmonkeyengine.github.io/wiki/jme3/advanced/mouse_picking.html

and yes to you to sgold

thanks mit. and atm I’m taking a break from programming. I’ve been head to the wall with tutorials for three weeks. I literally can type three just off of memory. Thanks guys.