Jump to content

  • Log In with Google      Sign In   
  • Create Account


Aim using a vector?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 miicchhii   Members   -  Reputation: 212

Like
0Likes
Like

Posted 20 July 2012 - 03:50 PM

Hey all,

I am new to Game development, i just did some simple 2D games (http://langeder.no-i...=spaceshooter_2),
but now i work on a 3D game and need some informations.

Its an FPS and i have the xyz Coordinates of the Player and a Hitbox (to begin with one).
Now i need to know how to do the aiming the best way.

I thought about using a vector, from the one end of the gun to the other,
and then calculate if it would collide with the box if extended.

Is it proper to do it like this or are there better ways?


Thanks already!



Greetings, michi

Sponsor:

#2 khagin   Members   -  Reputation: 110

Like
0Likes
Like

Posted 20 July 2012 - 04:07 PM

You could have a bullet be another collide-able entity, which is fired on a vector depending on the players aim. Then you just script out what happens when bullet entity collides with hit box entity.

#3 miicchhii   Members   -  Reputation: 212

Like
0Likes
Like

Posted 20 July 2012 - 04:34 PM

but then the bullet needs a speed and i have the risk of the bullet "tunneling" the target if the speed is too high

#4 Postie   Members   -  Reputation: 882

Like
1Likes
Like

Posted 20 July 2012 - 06:54 PM

If the speed of your bullet is very high compared to the movement of everything else in your world (for example a laser beam), you're better off using the vector approach, or more correctly, a Ray. A Ray has an origin and a direction, whereas a vector just has direction.

If the speed of your bullet is low enough that its reasonable that the player will be able to see it coming and dodge it, then you'll have to use collision detection. There are ways of preventing situations where collision detection misses a collision due to the speed of the projectile, you can simply test against an object that is extruded forwards in time by a certain amount, or use shorter timesteps to get a higher resolution.
Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler

#5 miicchhii   Members   -  Reputation: 212

Like
0Likes
Like

Posted 21 July 2012 - 02:35 AM

That was my thought about the missing, using a bullet.

Is there something ready to be used with C# and Unity?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS