Jump to content

Shooting


MaD2ko0l
 Share

Recommended Posts

Hi,

 

New to LUA and programming.

 

I have made a top down view scroller and i have got the basic controls working how i want them, however, i am a stuck with the shooting aspect and dont really know where to look.

 

the FPSPlayer/FPSWeapon lua isnt really helping me understand.

 

what i am after is when you click the mouse i want it to shoot a small laser beam from 2 points on the ship and simply move in a straight line and off the screen unless it hits and enemy.

 

Can someone point me in the right direction or know of a tutorial or something?

 

Regards,

 

Martin

Link to comment
Share on other sites

A missile beam if we could say.

You just need to create the missile at shooting canon when clicking on right mouse

(or more optimized, show some hidden missile instead of creating/detsorying it)

So show the missile at canon position, than move forward in player direction (PhysicSetPosition function), when missile has run some good distance just hide it or put it to a non visible position like (-500,-500,,-500)

Stop toying and make games

Link to comment
Share on other sites

Hi, I'm new and don`t have the exact answer but I hope theses recommendations would help.

 

If you need to use projectiles like on gun bullets and the velocity is really high, I would recommend using "raycasts" to find the collision point and then once you get the collision point (when you fire the weapon), you could do some visuals to show the damage. For bullets, it could be a simple 3D line that is draw for 1-2 frames (this would show the bullet trajectory)

 

For a rocket launcher, could be the same thing, you move the missile (you would need to "spawn" the missile from the launcher) to the collision point and put a particle trail behind (particle emitter attached to the missile).

 

If you decide to "lock" on a moving target with the missile, you should create a script that move and update the missile trajectory until it has hit the target. (when it was "locked" with the raycast)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...