Jump to content

[ACS] Spawn through player (howto)


michael

Recommended Posts

How to make spawned projectile go through player?

 

i have a script that spawns bullet at some distance +14 units from the player but it instantly collides with the player upon spawning. One way i figured that it may go through is with +THRUSPECIES flag and Species set as the player Species, but, there are different player species that may be defined, for example in BD it's "Marines" and in classical game it's "DoomPlayer".. also, this may affect multiplayer or coop with friendly fire, right..

UPD: hmm.. maybe could be solved with a bit of geometry

983749824.jpg.a7a8fab33648e86cac632e1d0197268f.jpg

 

i've managed to spawn some projectiles around the player.. not sure what the end result will be. Screenshot_Doom_20211220_000930.png.26fa04954624b00a1c581f7ecf3f2b71.png

the first one, is how i thought it would be. the second, shows ouch points in red (collisions with the player). the third and forth are projected around player radius. BUT, another problem appeared - player.radius doesn't define player hitbox as a circle, it's a square, so there are still ouches..

 

Screenshot_Doom_20211221_020934.png.f057d9278626cf3c1da65d57ecefb862.png

the hitbox is a square "drawn" with spawned red markers. it's not aligned with outer circle because of z-offset, but frontal view is okay red marker is closer to the player's view.. actually it's harder to determine their spawn position so i will use circular method. Now, spawned projectile doesn't collide with the player if not moving, any movement shifts hitbox and player catches own bullet..

 

some information obtained through experiments (in zandronum 3):

- to "guide" a projectile actor with ACS, it should be FastProjectile

- FastProjectile (or any?) being spawned inside player box doesn't collide (doesn't enter Death/XDeath states) with the player, it just keeps floating at the point where it's spawned.

- If you spawn a projectile somewhere underground(?) or at distant position from the player, like [x=32767,y=32767,z=0] or [x=playerX,y=playerY,z=-512], and later move it to the correct position with SetActorPosition(), it will move but DECORATE and ACS become unsync, which means there should be more delay() in ACS to obtain correct collision coordinates, so, the projectile must be spawned around the player, the point [x=playerX,y=playerY,z=playerZ+playerViewHeight] is perfectly fine.

- Collision may occur only after the speed is set, with SetActorVelocity()

- To set user variables of a custom bullet (for example, i have `Bullet:FastProjectile` parent where implementation sits and `RevolverBullet:Bullet` child with parameters set in Spawn: state with A_SetUserVar() and then goto super:Spawn) - 1 tick must be wasted

- Because of delay in 1 tick, "fired" projectile will collide with the player if it moves to the shot direction, the most simpler way i got around this, was the zeroing of player's speed SetActorVelocity() and after delay(1) restoring it back. It's the point in code, where some recoil factor may be implemented later.

 

so, not perfect but solvable..

 

 

 

 

 

 

Edited by michael

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...