- Home /
UFPS Projectile Spawn Point (SOLVED)
Hopefully this will help someone.
Ok, I searched for days to find the answer to this, but nobody had a solution for it. UFPS 2 actually deals with the ability to spawn projectiles from a set point, but it has so many missing features at the time of this writing, that it's no worth it to use over UFPS 1, and as such, there are still many, many users who are utilizing UFPS 1.
After days of fighting with the code, I managed to find the solution, so I'll post it below for anyone who needs it.
Answer by archelyte_vz · Jun 11, 2019 at 12:49 AM
Here's the solution I came up with
First, each weapon has a GameObject in it child heirarchy that is named "Muzzle", and if yours doesn't then you need to put it there for this to work.
Second, you need to locate the weapon prefab that you put in the "1st person weapon" slot under the render tab of vp_Weapon. Then give the prefab the tag "WeaponParent". It is important that you do this to the prefab and NOT the GameObject attached to your player!
Third, you locate the GameObject named "Muzzle" that is a child of the weapon prefab and give it the tag "MuzzlePoint".
Lastly, you are going to edit the script vp_FPWeaponShooter after line 269 which should be
if (Player.IsFirstPerson.Get())
After that specific line of code, place this
foreach (Transform child in transform)
{
if (child.CompareTag("WeaponParent"))
{
foreach (Transform grandChild in child.transform)
{
if (grandChild.CompareTag("MuzzlePoint"))
{
m_ProjectileSpawnPoint = grandChild.gameObject;
}
else
{
m_ProjectileSpawnPoint = Transform.GetChild(0).Find("Muzzle").gameObject;
}
}
}
}
What this does is locate the muzzle GameObject and sets it as the spawn point for the projectile. You'll then have to give the projectile it's own movement script if you haven't already.
If the spawn point is still a bit off, you'll have to adjust the location of the muzzle as shown in this tutorial
https://www.youtube.com/watch?v=OiyDit9KwOk&list=PLgtYBAm7mQcjRZie7GGeMgLACu1uimKte
Hope this helps, Cheers!
Answer by sas67uss · Jul 26, 2020 at 09:21 PM
very nice . do you know how can modify ufps scripts to that the Crosshair and ProjectileSpawnPoint follow the weapon recoil motion after firing and generally weapon motions in bob and shake and etc? As default the crosshair and fire point has been freezed in center of screen and it is very bad .
Your answer
Follow this Question
Related Questions
Bullet ricochet 0 Answers
UFPS and Photon 0 Answers
Gun Fire, sparks on Collision 1 Answer