Z
Z
ZeroGamer2021-03-08 20:47:16
Unity
ZeroGamer, 2021-03-08 20:47:16

How to make an object rotate towards another object after destroying another object?

There is a turret, it turns towards the enemy through FindGOwithTag, shoots and destroys it, but then it does not look for a new object, but remains to shoot in the direction where the destroyed object was before

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2021-03-08
@freeExec

And what do you want from us. The way you write the code is the way it works, it doesn’t invent or miss anything superfluous. If he is not looking for a new goal, then you have described the task to him so crookedly.

S
Sergey Vodakov, 2021-03-09
@WaterSmith

The question is what do you do after destruction. And how does your turret determine that the object is destroyed.
Let's assume that you just call FindGOwithTag in a loop and after destroying the target, the turret still finds it, so you don't destroy it, but for example you just hide it. Try to change its tag before destroying the object. Then, even if the destroyed object remains in the scene for some time, the turret will not find it and will switch to another object.
Well, maybe you haven't cycled at all, and you're only looking for the target once. With telepaths now tension, they are in great short supply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question