I have a game project. You have a ball that you can control with arrow keys. Purpose is, you will collecting an object. Object will destroy when i going over it, and respawn in random location of ground. Btw, you need to do that in 30 seconds. I couldnt destroy and respawn part. May you help me? (C#)
You can use collisions to destroy object. Run over it and yield. After that you can create couple of spawn points (for more randomness you can move the spawn points).
Related
I am making a game in Unity that is a combination of gorilla tag and minecraft and I am having trouble with using the RawAxsis1D.RIndexTrigger (top right quest 2 controller trigger) to destroy objects. (Some of my objects I'm trying to destroy have children.) I am also using raycasing so that it will make it so it will destroy the object the player is looking at, so far everything I have tried has failed.
Can anyone help me out? I am happy to provide any further info.
Main problem: when I add my script to my player, it did not do anything when the trigger was hit.
So I'm working on a zombie game and I want my zombies to be able to climb/jump over certain obstacles around the map. I know that I can create nav mesh links to achieve this but when doing it it feels forced as the zombies will go to the link to connect the climb/jump instead of just going over the obstacle. I am having trouble in my research finding an effective way to do this.
Basically here is what I want to achieve:
1.) When a zombie reaches a certain obstacle (fence, car, crate, etc.) that is climbable, instead of running around the obstacle to get to the player I want the zombie to climb or jump over the obstacle.
2.) When the player climbs on top of an obstacle I want the zombies to also be able to climb on the obstacle to be able to attack the player.
Does anyone have suggestions on effective ways to go about this or possible methods I could further research? From the hours I've spent researching this I'm not having any luck finding something that goes with what I want to achieve.
I just purchased the A* Pathfinding asset from the Unity store. I have a few questions on getting it set up. My current problem is the AI Destination Setter will only follow the player's "0th" position. It goes to wherever my player starts at and does not update to the current position. (See Image below)
I have a game object prefab called "Essentials Loader" that I drag into every scene. This has things like my Player prefab, Game Manager, UI Overlay, Audio Manager, and other things that will be needed in every scene. I set it up this way for two reasons. 1. It prevents me from forgetting to drag in anything important into a new scene. 2. If I completely re-do the player prefab I only need to swap it out in the Essentials Loader and not in every single scene.
The code in this Essentials Loader checks for accidental duplicates and deletes them to prevent unwanted issues between scenes.
Temporary Solution: I have taken the player prefab out of the Essentials Loader and dragged it into the scene. Now when I assign the "AI Destination Setter" Target transform to the player from the scene and not the project window, it works just fine and follows the player correctly.
My question is: is there a way that I won't have to do it this way? I do plan on completely changing the player prefab a little while down the road and I would hate to have to make that change in every single scene. I would like to still have the player prefab in the Essentials Loader and have the enemy still follow me.
Instantiated objects are stuck at initial position while it was working just normally with no change in code.
I am making a spaceship based game and i was able to making instantiation of prefabs normally until i started adding layers so that the instantiated objects of different kind do not collide. But meanwhile when i ran the game my instantiating objects got stuck at the starting location of their launch.
You probably messed up your Layers a little bit.
To fix this problem go to the Physics 2D Manager (Edit > Project Settings > Physics 2D).
At the bottom you can see the layer collision matrix. (The fancy looking thing with checkboxes)
Because I don't know which layers you have I'm using "Player" as the layer for your player spaceship and "PlayerBullets" as the layer for the bullets your spaceship shoots.
You can now disable collision between the player layer and the player bullet layer.
If your enemies can also shoot, I would create a new Layer called "Bullets". The player layer should be able to collide with enemy bullets, but not with its own bullets.
In my game I am using Destroy(gameObject) for some gameobjects to pass them on another level. Now the problem is after my player dies there are objects left on the scene when I restart the game after the player dies, I only want the objects that i created when the game started.
How can I accomplish this?
Store the player created gameObjects in a list, then call Destroy() on them after a restart.
First of all if you need to destroy object that you marked with DontDestroyOnLoad you are doing something wrong.
Use it only on objects that you really want to keep across the scenes. If you need to make changes in these objects, just change parameters values and make other objects live only in scenes where they belong.