Author Topic: First-Person Shooter movements  (Read 4335 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
First-Person Shooter movements
« on: September 11, 2010, 11:12:14 am »
Have you any idea how to do fast FPS movements? I tried some ways, but frames went down to 13 from 56... thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: First-Person Shooter movements
« Reply #1 on: September 11, 2010, 02:07:23 pm »
That's a bit too vague...what exactly is causing the slowdowns?

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: First-Person Shooter movements
« Reply #2 on: September 11, 2010, 03:24:13 pm »
How can I find object3D under camera and determine distance between them?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: First-Person Shooter movements
« Reply #3 on: September 11, 2010, 06:20:26 pm »
World.calcMinDistance(...) is meant for that. It may not be the best way to do collision detection though...it depends on the scene. More information about collision detection can be found in the wiki: http://www.jpct.net/wiki/index.php/Collision_detection

On Android, collision detection can be quite a bottleneck, because floating point performance can be pretty bad and Dalvik is also pretty bad in doing more intense calculations. Using an OcTree *might* help in that case.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: First-Person Shooter movements
« Reply #4 on: September 11, 2010, 06:48:37 pm »
Can you give me advice, how to do it more efective? :) ... Do you have any simple source of game, where can I find code with it? ... if you look at nova game, you have to say, it must somehow work, but how :) ... I try ocTree ...
« Last Edit: September 11, 2010, 06:51:29 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: First-Person Shooter movements
« Reply #5 on: September 11, 2010, 08:37:29 pm »
That's a native application, you can't really compare that to the performance that you'll get with the Dalvik VM. However, it should be possible to get this reasonable fast even with Dalvik. Giving an advice is difficult, because i've no idea how your level/game/code looks like. But i can give some general hints:

1.) When using calcMinDistance, watch the threshold value. When using "normal" collision detection, watch Config.collideOffset. Choose reasonable values depending on your level but don't use unnecessary high values, as this will slow down the calculations.

2.) set Object3D.setCollisionOptimization(true) on your objects

3.) Consider using an OcTree. By default, the OcTree will be used for rendering AND collision detection. You might want to limit it to collision detection...just see the JavaDOC of the class for more information

4.) Consider to use an alternate collision mesh, i.e. when rendering, you are using a high detailed mesh of the level, but when doing the collision detection, you us a simplified version with less polygons. You can achieve this by switching visiblity of these meshes before and after rendering for example.