FINALLY! Resolved! Here’s what I used (added inside and after the whole raycast check for shooting/hitting an object and stuff):
GameObject theObjectHit = hit.collider.gameObject;
GameObject temp = Instantiate(bulletDecal, hit.point, Quaternion.FromToRotation(-Vector3.forward, hit.normal));
temp.transform.parent = theObjectHit .transform;
And the most important part, which took days to get a proper answer for, was that I needed to assign a temporary variable when instantiating the decal object so I could then use that temporary variable to assign the parent to the decal. Without that one “temp” part it was just errors constantly or it not doing what I wanted it to do.
Original post:
I want to be able to shoot things like the enemies and have the bullet decals appear on them, and when the enemies move I don’t want the decals to just be floating in the air, which they currently do.
Does anyone have a nice and simple way of doing this they could share with me?
Note: When I say “enemies”, I’m obviously going to make decals appear on pretty much anything I shoot, and an enemy is just an example of one thing in the game that might be moving. There’s also the likes of automatic doors and crates that break and change shape as well. So I want the code to be workable on all those kinds of things too.