简体   繁体   中英

Libgdx implementing shooting (collision between bullet and objects)

I am new to 3D programming, just started yesterday.
I am just trying to create a simple game, where i move in 3D space, but collision detection works in 2D top down space, cause my character can't jump. So collision happens only on X and Z axis.
But now i think about implementing shooting, where the bullet flies in the direction my camera is pointing (first person camera). But i have no idea how shooting is normaly implemented in 3D games? Is a Bullet an object, which is drawn, like in many 2D games, and moved at high speed? Or is it just a line, which isn't even shown sometimes? And how can i check for collision with that line without iterating throught all walls and mobs? I know you can find the areas throught which the bullet flies, but isn't this a big calculation when the line can go in every direction in 3D space?

Depends if you want to show the bullet, then you can make a bullet model and make it move very fast.

These are good options each one better than the previous

  • You can check for collisions iterating all the objects.
  • You can have all the objects in nodes that have a reference to their neighbors and check collisions on them
  • Same as previous, but you take into account the direction vector of the bullet and only check the neighbors that are in front of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM