Be the first to post for `Weapon Pickup Points`

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.

i have taken the liberty to make a small modification, that would make a massive improvement on performance, on the structure that we have just learned, i thought i’d share it.

basically, instead of making the WeaponPickUpPoint get executed only in edit mode, and get executed on every single update. we can make a public function, that does the job, and simply call it from a custom editor script. as follows in the below picture.

image
basically, we create a custom editor as follows , now the Refresh Prefab function, would get called only when you change something on the specific game object that has the WeaponPickUpPoint.
really neat, and a big improvement, for a small change, so i thought i’d share it.

4 Likes

Very nice.

I’m having some issues, in class 146 from core combat, I should make a pickup point, but when my weapon appears, it’s in a wrong place and I can’t move, just in play mode, don’t know how can I solve this
(I thought it could be the ‘weapon.transform.position = Vector3.zero;’ part, but already tested and doesn’t change anything )

I’m not an expert, so if this doesn’t work I will be out of ideas, but have you tried resetting the Transform component for Weapon Pickup in the editor? (top right corner of your first screenshot)

Yes, know I did, actually, I removed the [ExecuteInEditMode] and it’s placed in the right position, but I’m not able to get the new weapon, and always when a pass through the collider I lose my old weapon, do you know how I can solve this?

Comparing your code and screenshot to mine, the main differences are:

  1. You haven’t made Weapon Pickup a prefab, though I’m not sure that would effect the functionality.
  2. You haven’t selected “Is Trigger” in your collider component.
  3. You haven’t finished the lesson (i.e. there is code Ben showed that you haven’t written yet, including the OnTriggerEnter method).

I think the best thing you can do is start the video again, follow along as Ben makes his, and ensure that you didn’t miss anything the first time. That’s what I would do.

let me show you how it is now


You’re now actually ahead of me in the course, but comparing your code to Ben’s, I notice a few differences, the one that seems most relevent is that you don’t have:
weapon.transform.position = Vector3.zero;
in your InstantiateWeapon method.

Whenever my code doesn’t do what is expected, I check it against Ben’s by going to the Lecture Project Changes link in the resources, which for this lecture is


and I compare my code to Ben’s line by line.

Put the line I mentioned above in, and see if that helps.

When I use this line my weapon get Stuck on transform zero, and I can’t move, This pat it’s solved, But what isn’t is that I’m not getting the weapon

Sorry I couldn’t be more help, I only just started learning to code a few weeks ago. Hopefully someone who knows more than I do will get involved and help you out.

Good luck!

1 Like

thank, you anyway c:

1 Like

Privacy & Terms