#Simplest Issue is legitimately driving me crazy. I'll even venmo you $5 I literally just want a fix

1 messages · Page 1 of 1 (latest)

ebon cradle
#

Hi, I'm a sophomore in college. This is for a class. I'm extremely new. Please be aware of that.

I'm making a unity fishing game and I have it right now so that when you cast your line (i.e. duplicate a bobber where the indicator was) it starts a fishing minigame, then if you catch or lose the fish, it triggers a respective UnityEvent to destroy the fish. My issue is that I have 3 different kinds of fish. Big, medium, and small. So I wrote a bookmarker script to determine which fish you hooked and only destroy that one, not all the fish.

I have brought this script to a tutor 3 times, I had my friend look at it, I have had my professor even rewrite it for me.

The current issue is that, yes, it will temporarily get rid of the specific fish. That is, until you cast your rod again and it will reappear as a child of the bobber where the bobber appears. Think of it likes its glued to the bobber.

Here is the script: https://hastebin.com/share/ogefuhetet.csharp

If anyone needs me to hop into a call and screenshare I'd be more than happy I literally just need this done to move on.

dense ginkgo
#

I'm assuming this object gets disabled and re-enabled. Your issue is likely that OnTriggerEnter runs even if the object with the trigger is disabled (so you can activate an object by getting close to it, for example)

#

So you're parenting the fish to the disabled collider, and when you call DestroyHookedFish, you are only destroying the last fish to touch the line. Any other fish that are children of this object would be stuck there forever

ebon cradle
dense ginkgo
#

You specifically set it to be a child of this object

ebon cradle
#

Oh yes, sorry. That was the bit my professor added so I forgot.

#

So would the solution be to unparent (if possible) in DestroyHookedFish? Or to find a way to not parent at all?

dense ginkgo
#

You should probably unparent whatever fish is currently attached before attaching a new one

#

So if hookedFish is not null, set its parent to null before setting the new fish to attach

ebon cradle
#

Should I do that in DestroyHookedFish?

dense ginkgo
#

No, in OnTriggerEnter. Before attaching the new fish

ebon cradle
#

oh ok

dense ginkgo
#

Check if the hooked fish is not null, and if that is the case, set the hooked fish's parent to null before you set the new hooked fish

ebon cradle
#

Is this what you mean?

dense ginkgo
#

Yes, that should un-parent any fish before adding a new one

ebon cradle
#

It doesn't work 😭

dense ginkgo
ebon cradle
#

No I don't think so

#

Just to make sure I understand what you're asking, like even though the bobber is disabled, if a fish ran over where it was would it trigger an event?

dense ginkgo
#

Yes

ebon cradle
#

No that is not the case

dense ginkgo
#

So, what is the current issue after making the change to it?

ebon cradle
#

It's the same as square 1.

#

Object is somehow still parented.

dense ginkgo
#

Well, it only ever gets un-parented when you call DestroyHookedFish or pick up a new fish. Are you doing either of those?

ebon cradle
#

Huh? Didn't we just unparent it in the OnTriggerEnter?

#

Well wait let me think about this

dense ginkgo
ebon cradle
#

I want the fish to be gone by the next time you cast the rod, regardless of whether you hit a fish or not.

dense ginkgo
#

It becomes a child object when you touch one, unparenting whatever fish was there before. The only other time it becomes un-parented is in DestroyHookedFish

ebon cradle
#

Now that I think about it