🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3rd person spaceship camera and combat

Started by
6 comments, last by Tom Sloper 3 years, 9 months ago

Hi,

I am shooting a laser from my spaceship straight into the direction the player is looking into. However, the camera sits above and behind the weapon/center of the ship, so it hits when the target is beneath the crosshairs.

Any ideas on how to solve this problem? I could move the hitbox of the shot to the camera ray and move the particle effect slowly into it as well, but that doesn't seem like the best option…

Advertisement

I'm not sure I understand exactly what the problem is… (maybe a language barrier since I'm Norwegian :P ).

Am I correct to assume that you have a 3rd person view where the camera is behind and slightly above the spaceship, and the laser is coming out too low?

If this is the case, is there any reason why you can't do a Raycast from the ship's weapon exit point to the camera center (middle of the crosshair)?

If I misunderstood, please feel free to explain the problem further.

Andy Pett

AndyPett said:
Am I correct to assume that you have a 3rd person view where the camera is behind and slightly above the spaceship, and the laser is coming out too low?

Yes, but it's coming from where it's supposed to come from - the ship's laser cannon.

AndyPett said:
If this is the case, is there any reason why you can't do a Raycast from the ship's weapon exit point to the camera center (middle of the crosshair)?

But where is the camera center? The laser shoots up to 500 meters into the distance but the target could be closer and then it wouldn't be hit when the crosshairs is directly pointed at it.

On the other hand, if I used the camera center as the hitbox for the laser and it shot straight, the enemy would think they avoided it because they were above the particle effect, but they were actually in the hitbox for the camera.

Well, if you do a Raycast 500 meters into a given direction, the RaycastHit (I'm assuming you use Unity here, but it will probably be similar for other game engines) will return the closest object that is being hit unless it's being told to ignore it (make sure the entities that can be hit has a collider on it).

So even if the object is closer than 500 meters, if it is within the Ray being cast, it should return as being hit.

Do you have an example or some source code to show the problem?

Andy Pett

Moving this to a more appropriate forum. This is not a Game Design topic.

-- Tom Sloper -- sloperama.com

Tom Sloper said:

Moving this to a more appropriate forum. This is not a Game Design topic.

I have to disagree. I know how to do the programming. I just don't know what behavior it should have.

Beosar said:
I have to disagree.

It sure looks like a technical issue to me, not a design issue.

-- Tom Sloper -- sloperama.com

This topic is closed to new replies.

Advertisement