www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on September 11, 2010, 11:12:14 am

Title: First-Person Shooter movements
Post by: Thomas. 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
Title: Re: First-Person Shooter movements
Post by: EgonOlsen on September 11, 2010, 02:07:23 pm
That's a bit too vague...what exactly is causing the slowdowns?
Title: Re: First-Person Shooter movements
Post by: Thomas. on September 11, 2010, 03:24:13 pm
How can I find object3D under camera and determine distance between them?
Title: Re: First-Person Shooter movements
Post by: EgonOlsen 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 (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.
Title: Re: First-Person Shooter movements
Post by: Thomas. 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 (http://www.youtube.com/watch?v=oQ4N7QAlHd4) game, you have to say, it must somehow work, but how :) ... I try ocTree ...
Title: Re: First-Person Shooter movements
Post by: EgonOlsen 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.