Weapons not spawning from next to enemy

Continuing the discussion from Projectile Parent Issue, any help appreciated:

After much clicking around on different videos and the video that actually has the solution constantly changing - I’ve come back to here.

If I take out the animations for the weapons it works - the axe comes from where the gnome is placed - it just doesn’t spin, add the animation and there’s a little glitch next to the gnome - presumably an axe appearing then immediately disappearing, then axes start appearing at the point where I created the original animation.

I’m using Unity 2017

Hi Dominic,

Could you zip up your project files and share them please, I will be happy to take a look. There could be a number of factors, such as Position being recorded in the animation, Prefab Instantiation and so on, it’s probably going to be easier to just look at the project directly.

The forum will allow uploads of up to 10MB, if your project files (zipped) are larger than that you would need to use a service such as Google Drive or Dropbox, and then share the URL.

OK, there might be some weird bits in there as a result of my trying to fix the problem.

Also I started a new prefab folder because the original was a bit messy as imported from laser defender game but didn’t want to delete any of it in case I needed it. Basically ignore Prefabs, I’m using _NEW Prefab Folder.

And I’m away from home from Monday so no urgency on this.

Many thanks

https://drive.google.com/file/d/1IKUPb8K32RWHGhkEEc1nlg1ttVrYXOWB/view?usp=sharing

Hi Dominic,

There’s quite a lot going on in your project, e.g. not easy for me to establish what I’m supposed to be looking at.

Can you tell me which scene to open where a defender produces a projectile in the wrong place so that I can take a look please. Thanks.

Oh damn! Yeah so I deleted the weapon animations because they were making the weapons appear in the wrong place, I suppose I could have just taken their animation controllers off the respective weapons but i’m a bit too impulsive sometimes…

My bad, sorry! If it is addressed in a future video I could just wait.

Hey,

Yeah, not a lot I can do to experience the issue and provide a suggestion as how to resolve it without the same conditions. If you have a backup, from before you made the deletions, I’m happy to take a look at that?

The projectiles instantiating at the correct position is definitely covered in the course, I couldn’t tell you which specific lecture, but then it’s better to not jump around them really anyway, and to just progress through them.

On that note, Rick is currently in the process of remastering Glitch Garden, he’s only a few lectures in so far, so at the moment, from the game’s perspective, you are probably a bit further ahead, but an option may be to restart the section, but from the remastered version instead? Alternatively, back peddle a few lectures and check that your project is where it should be against the lectures and then progress forward again.

I am happy to help but without a project with the problem all I would be giving you is a set of instructions on how to achieve it, as opposed to how to fix it, the former being exactly what you have in the course :slight_smile:

Which specific lecture have you got to by the way?

If I had to make a guess as to the issue you experienced, and it would be just that without seeing the project with the issue, I would suggest that maybe you had the position for the projectile sprite in the animation as well as the rotation. You should only need the rotation as the projectile will be positioned, in code, via the Instantiation, using the Gun transform’s position. (from memory)

Ah! That last paragraph sounds like you might have hit the nail on the head!

That’s how good you are Rob! You don’t even need my code.

1 Like

If you think you may have include position in the animation, that would explain any off-set. You would effectively be spawning the projectile at the transform position of the gun, but then any position values you had set in the animation would move the projectile away from the point at which it spawned.

Certainly something to check for. :slight_smile:

Privacy & Terms