Hello everyone
Since i am quite new to unity, i would ask for some help. So far i learned thanks to the questions here, how to spawn an object at a certain position or trigger an event when entering a colider as a player.
But what i desperately need now is a way to spawn an object randomly always at the same distance to the fps player, somewhere in his field of view.
So the game starts, i see a blue light, i am running towards it, after 5-6 seconds i nearly reach it, it disappears and instead is respawnd somethere in the field of view, but randomly. So when my field of view is lets say 120 degree, than my center is 60 , and the blue light should spawn randomly , always in the same distance to the player somewhere in those 120 degrees, so the player can see it and run again towards it.
My problems are:
- how to get the field of view
- how to spawn something equally distanced in the field of view (when spawned far from - center of field of view, it should be a little more near, since it should be half a circle , so the distance does not change)
In Addition to this i need to spawn a comet or something like this. I guess when mastering the blue light spawning i should be capable of doing so. But here my problem is:
- How to get an object to move in the direction, the player was at moment of the spawn of the object ?
And my last question:
To what object should i than attach the scripts? I have prefab of the blue light, so i thought about giving it a colider, so it can destroy itself and respawn.
But when i attach a respawn script to the comet, which should appear with a 3 sec delay, will the sript work, if the objct is destroying itself, and then after 3 sec respawning ?
Or should i attach it maybe to the player ?
thank you