How to make a gun that shoots projectiles not bullets
10 replies, posted
How to make a gun that shoots projectiles not bullets and im pretty new to this whole coding thing so dont get me banned again
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/Create]ents.Create[/url]
Call somewhere in PrimaryAttack and do operations on the entity ( and its physics object ) like
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetVelocity]Entity:SetVelocity[/url]
I think this would be a good starting point if it's still up to date:
[url]https://wiki.garrysmod.com/page/Chair_Throwing_Gun[/url]
Spawning entities is a pretty expensive way to make physical bullets like battlefield if that's what you're trying to do.
I'd try to find another solution for bullet drop (again, if that's what you're trying to do), but it might be hard.
[QUOTE=overki11;51970517]Spawning entities is a pretty expensive way to make physical bullets like battlefield if that's what you're trying to do.
I'd try to find another solution for bullet drop (again, if that's what you're trying to do), but it might be hard.[/QUOTE]
It's not expensive if you were to use a single manager entity so much as it would just act poorly on low tickrates.
[QUOTE=code_gs;51974485]It's not expensive if you were to use a single manager entity so much as it would just act poorly on low tickrates.[/QUOTE]
What do you mean a single manager entity?
[quote]Tip: If you're creating lots of individual objects all the time, consider rolling them all into a single manager entity. This is how Left 4 Dead handles huge numbers of infected: they are all "finger puppets" of the director.[/quote]
Source: [url]https://developer.valvesoftware.com/wiki/Entity_limit[/url]
You can do something similar with bullets by having a single manager that stores a table of models to draw, their collision bounds, etc. and simulating it per tick. Would be a LOT of extra work, but can avoid having to create a bunch of entities.
[QUOTE=code_gs;51976328]Source: [url]https://developer.valvesoftware.com/wiki/Entity_limit[/url]
You can do something similar with bullets by having a single manager[/QUOTE]
Any reason not to just to it with a nested table and the think hook?
[QUOTE=TFA;51977692]Any reason not to just to it with a nested table and the think hook?[/QUOTE]
You can do that, but you can only do simple collisions with that. Having a manager entity gives physics collision callbacks for immediate effects. It's really up to personal implementation.
Why does the bullet need to be an entity when you can just math everything?
[QUOTE=arow1234;51977761]Why does the bullet need to be an entity when you can just math everything?[/QUOTE]
It doesn't, it's just easier to understand what is happening / implement entity projectiles.
Sorry, you need to Log In to post a reply to this thread.