felixk4 Posted March 17, 2017 Share Posted March 17, 2017 I know about the OnHit() function but is there a function that can get a reference to a fired projectile? Example: Player shoots projectile>Script gets reference to fired projectile>Script kills/deletes projectile. Link to comment Share on other sites More sharing options...
ablindm4n Posted March 17, 2017 Share Posted March 17, 2017 (edited) Not sure about referencing the actual projectile (like an arrow etc), but you can get the location of the impact by applying an explosion to the projectile, and on the explosion spawn on object. Then on that object place a script and run things on Event OnLoad(). Edit: You could probably then use something like FindClosestReferenceOfTypeFromRef to get the actual projectile reference. Or maybe it would work just calling this on the player as soon as you've fired the weapon to track the projectile as it flies. Edited March 17, 2017 by a_blind_man Link to comment Share on other sites More sharing options...
felixk4 Posted March 18, 2017 Author Share Posted March 18, 2017 Not sure about referencing the actual projectile (like an arrow etc), but you can get the location of the impact by applying an explosion to the projectile, and on the explosion spawn on object. Then on that object place a script and run things on Event OnLoad(). Edit: You could probably then use something like FindClosestReferenceOfTypeFromRef to get the actual projectile reference. Or maybe it would work just calling this on the player as soon as you've fired the weapon to track the projectile as it flies.Hmm interesting that should work! :happy: Link to comment Share on other sites More sharing options...
steve40 Posted March 18, 2017 Share Posted March 18, 2017 (edited) I know about the OnHit() function but is there a function that can get a reference to a fired projectile? Example: Player shoots projectile>Script gets reference to fired projectile>Script kills/deletes projectile. Simply not possible. Projectiles are base objects, they do not extend (and cannot be cast as an) ObjectReference, so, no, they do not have in-game reference instances to be gotten. That's why you can't attach scripts to them either. Even if they did, bullets, lasers, beams, arrows etc, shoot too fast for any script to be able to do anything before they hit their target and cease to exist. Edited March 18, 2017 by steve40 Link to comment Share on other sites More sharing options...
Reneer Posted March 19, 2017 Share Posted March 19, 2017 (edited) I know about the OnHit() function but is there a function that can get a reference to a fired projectile?ÃÃÃÂ Example: Player shoots projectile>Script gets reference to fired projectile>Script kills/deletes projectile.ÃÃÃÂ Simply not possible. Projectiles are base objects, they do not extend (and cannot be cast as an) ObjectReference, so, no, they do not have in-game reference instances to be gotten. That's why you can't attach scripts to them either. Even if they did, bullets, lasers, beams, arrows etc, shoot too fast for any script to be able to do anything before they hit their target and cease to exist. It is totally possible to get the projectile "reference" to a projectile - I've done it myself for two unreleased mods that I'm slowly working on. There is the issue of the projectile disappearing before the script can grab it, but it is possible. Now, deleting the projectile, as you noted, can't be done, because as you said it isn't an ObjectReference. Edited March 19, 2017 by Reneer Link to comment Share on other sites More sharing options...
Recommended Posts