|
|
|
|
Reply From: |
eons |
look_at is your friend, the mouse position you can get with the Viewport , the Look At Pointer demo has some smooth movements applied to that too.
You can look_at this tutorial for more detailed information on the basics of rotations (lerp and stuff like that)
http://codetuto.com/2016/01/godot-engine-movement-and-rotation-basics/
For the shot, since shotguns tend to be instant and short range, you can cast a couple of rays from the shotgun to represent the pellets if is the way you want to apply damage and use a particle effect for visuals.
The other option is to instance bullets or create a triangle area if the damage is full area with a simple animation.
Hey thanks for the rotation towards mouse resources. Do you know of any tutorials that teaches the instant shooting with the rays?
Prestidigitator | 2016-10-15 21:16
No, it just occurred to me while thinking about the tools godot has for something like that xD
Never used rays yet (I’ve come from engines where rays are not a common tool) but they seem useful for many things.
I can think on something like:
You can enable all the rays when shot takes place (with code or AnimationPlayer for a delay) and check them one by one.
No need to check distance to calculate damage, all can do the same, the closer, the more rays hit a target.
Walls and front targets can block the ray so it nulls common area shot issues.
If you use a Gun class with bullets, the rays can be a non moving bullet (individual or in group), just instance, cast and dies.
As a con, invulnerability frames after hit can’t be applied instantly this way, you will have to delay it or control in some way.