Jump to content

Reference to projectile?


felixk4

Recommended Posts

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 by a_blind_man
Link to comment
Share on other sites

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

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 by steve40
Link to comment
Share on other sites

 

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 by Reneer
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...