Topic: "Sticky" Projectiles

So there's a way to have sticky particles (Which are particles that move with the player), is there any way to copy that behavior to projectiles? That way we could make it look like projectiles orbit the player or have a constantly active hitbox surrounding the player.

Share

Thumbs up Thumbs down

Re: "Sticky" Projectiles

Its a bit complicated, but there is a a way this can work.

Under Projectile.cs, add this line around line 27:

public bool stickToCharacter;

Under MoveEditorWindow.cs, add this before line 3652 (before the "Apply Gravity" line):

moveInfo.projectiles[i].stickToCharacter = EditorGUILayout.Toggle("Stick to Character", moveInfo.projectiles[i].stickToCharacter);

Now under ProjectileMoveScript.cs, add this around line 214 (before the comment line that says "// Get Auto Bounds"):

if (data.stickToCharacter)
{
    fpTransform.position = myControlsScript.HitBoxes.GetPosition(data.bodyPart);
}

This code will force the projectile to be constantly sticking to a specific body part. To make a projectile rotate around the character, make a game object rotate around the character, assign it a body part under Character Editor -> Hitbox Setup (collision type = no collider) and set it as the Body Part Origin under your projectile move file.
Warning: Manual rotation may not perfectly synchronize with the rollback netcode.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.
Don't forget to check our discord channel.