How do I use trigger to destroy blocks on quest 2 unity? - c#

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.

Related

How to turn off Pathfinding in navmesh unity?

I use navmesh agent for my Isometric game (diablo like)
how then in all diablo-projects did they make it possible to rest against the wall?
how to off pathfind in nav mesh agent ?
I just want to hit the wall (or game object)
Example
ExampleInPoe
I tried everything, I can't figure out how to do it
You have to use NavmeshObstacles like explained here https://learn.unity.com/tutorial/navigation-basics#5c7f8528edbc2a002053b49c in Step 5.
So your navmesh basically ignores the wall - but the object prevents the player from passing. During runtime you can just remove the object and the path will be walkable.
Update:
In order to force the player to run into the wall (I assume when you say 'rest' against the wall you mean that), you could add a script that recognizes the player when they're close and then takes over their movement to let them smash the wall.
But this isn't a specific question anymore. So I'd rather recommend that you check out the Unity Tutorial section: https://learn.unity.com/search?k=%5B%22tag%3A5d351f087fbf7d006af48180%22%5D And try to get a better understanding of navigation and player movement in general.

Unity - How can i make my turnbased AI movement move one at a time

Not sure if I described the problem correctly in the title, but I'm making a turn-based game and have the enemy movement AI finished. The problem I've got stuck on is making each enemy move separately:
Enemy 1: move and attack
Then
Enemy 2: move and attack
and so forth.
I suppose I could do separate scripts but that would just be a mess in the long run. Do any of you know a more straightforward way of doing it using the same script?
I'm kind of new to game dev and this forum so if this is posted in the wrong forum, please tell me where I should post it instead:)
I propose the following solution, use a public static UnityEvent when you put each enemy's logic then call each method of the UnityEvent one by one when it's the enemies turn to play.

Load Scene is not restarting the scene properly

I'm trying to restart my game when the player loses, I play a coroutine which makes the player ignore collisions and falling off the platforms. Then when the player click a button, the same scene is reloaded.
SceneManager.LoadScene("GameScene")
But when the scene loads again, the player is still ignoring collisions and falls, it's like the scene is loaded but not the same way when the game is played for the first time.
¿How can I reload the scene properly without closing the aplication and opening it again?
Thank you.
The problem is that you are using Physics2D.IgnoreLayerCollision for this.
This property is global, it affect all scenes, and not related to the specific scene. What SceneManager.LoadScene resets is only property related to the specific scene or the objects in the scene.
You have 2 options here:
Don't use IgnoreLayerCollision. An alternative may be, for example, to disable all colliders on the player. You can use GetComponentsInChildren for example to find all the colliders.
Reset IgnoreLayerCollision manually.

How to communicate between 2 scenes in Unity?

I would like to make a color system for my player. In my game scene the player can pick up the coins and the amount of coins will be save with playerprefs , but I don' know how can I use the amount of coins in my menu scene.
And I need some help to a player color selecter too. When the player select a color than in my game scene must instiate the player with the color.
Soo I think , i need to know how to communicate between 2 scenes.
Can somebody help me with some tutorial?
There are multiple ways to achieve this, which I feel comes down to a matter of taste: save data to file, use DoNotDestroyOnLoad...
But from what I understand, the recommended way now is to create a "manager scene" which will stay alive throughout the lifetime of your app and pass data to and from your other scenes as they are opened and closed, instead of using DontDestroyOnLoad:
It is recommended to avoid using DontDestroyOnLoad to persist manager GameObjects that you want to survive across scene loads. Instead, create a manager scene that has all your managers and use SceneManager.LoadScene(, LoadSceneMode.Additive) and SceneManager.UnloadScene to manage your game progress. src
See the Unity guide here. Basically you would have 2 scenes open at the same time, at any given moment: the manager scene and whatever the actual active game scene is. Then you can communicate between scripts in the two open scenes via event delegates. The way it would work is:
Player selects color in scene1
Color is sent from scene1 to manager scene via event delegate
scene1 is unloaded and scene2 is loaded
Color is sent from manager scene to scene2
This is the approach I've been using for a project now which looks like this:
"0-Attract", "1-Sealant", "2-Paint", and "3-Conclusion" are my actual game scenes, and "Manager Scene" contains everything that exists in every other scene (thus no reason to kill and respawn them) as well as all of my "manager" scripts which handle the passing of data between scenes.
Note that multi-scene editing can be confusing at first, as there are new things you need to pay attention to (i.e., which scene is currently "active" and what that means) so be sure to go through the unity guide I posed above. Good luck!
you can Call DontDestroyOnLoad method on any object that you want that will remain wen you are moving the a new scene so it will not be destroyed when scene is closing.

What is the best way to manage Player object of SteamVR plugin for Unity3D when change of scene

I am developping an application using the new version of SteamVR plugin (2.2) for unity and i need to navigate between several scene during the game.
I have for all my scenes a Player object coming from the SteamVR plugin handle input and event, who is a singelton dontDestroyOnLoad, and i don't know the best way to handle this object during the change of scene.
There is 3 options in my opinion :
For all scene a player object is present, but steamVR don't check if an instance already exist so i add this feature to have only one player after scene initialisation.
The other solution is to destroy the current instance before loading the new scene but with the new system of event made by Valve in this version i don't know if it's a good way to manage the fact to have only one player at the time, can potentiolly create event conflict (didn't saw yet).
The last one but not really confident with it is to let 2 player per scene and one of this is the good instance of the singelton class (way more anoying to get the good instance Player, and can i have conflict between them ?)
If someone have some idea or can give me better understood of my conception issue you are welcome :)

Categories

Resources