I am creating a HoloLens application with Vuforia, and i have a total of 9 markers and associated GameObjects with each marker. I want my application to show only one object at a time: for example, I scan the first marker, show the first object; when i scan the second marker, i want the first object to disappear and only the second object to show, and so on.
I tried adding a script to each GameObject that would destroy the GameObjects in the scene, but that did not work.
I have very little knowledge with C# so please point me to specific code.
Thanks all!
In order to control the maximum number of targets to be detected at the same time you need to use Vuforia's hint:
Vuforia::setHint(Vuforia::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, <desired number>);
This is what you asked - however, according to what you wrote in the comments this is not really what you need. If your want to use extended tracking for other targets, it means they have to be detected too. So, what you really need is - once you have a target, to know if it is extended right now or not, and act accordingly.
This is done via:
if ( result.getStatus() == Vuforia::TrackableResult::EXTENDED_TRACKED )
This is an option in the Vuforia configuration.
Select your scene's ARCamera asset
Click "Open Vuforia Configuration"
Change "Max Simultaneous Tracked Images" to 1.
I saw that you mentioned this doesn't work with Extended Tracking. I haven't noticed this behavior myself, but if needed you can manually toggle the active states of the objects with GameObject.SetActive().
Related
I am experimenting with Unity and have created a multi-player local coop environment. I have a Player Input Manger create a new player whenever a new device connects. These players have a Player Input component that is set to use c# events. Then I have some code that listen for the events and logs to the console. I want to be able to distinguish between players, but at the moment events get fired for every input on every device.
I have watched countless tutorials on the Input System, but local multiplayer never seemns to be addressed. All the solutions I can think off seem nasty. I can get it working with send, broadcast and unity's events, but I would like to know how to achive it with c# events.
I don't think you can through the event system, no.
However, if you use the Input Manager directly (i.e. Input.GetButtonDown()), then you can go into your project settings and set up the buttons and axes to be gamepad specific.
Essentially, what you need to do is duplicate all of the buttons and axes in the Project Settings Input Manager for however many players you want to support, and then go through them and set the Joystick index to a fixed custom value.
Then, instead of having, for example, a "Jump" button, you'll have "Jump 1" through "Jump 4", each unique to its own gamepad.
See the last entry in the Virtual Axes table for more info:
https://docs.unity3d.com/Manual/class-InputManager.html
I am creating a simple App on Hololens2 using Unity. I create two game objects and want them to move based on the user's head movement i.e. they do not stay still at a place in space but move relative to the user's head. However, I am not sure on how to enable this setting. Can someone please help?
The Orbital Solver provided in MRTK can implement this idea without even writing any code. It can lock the object to a specified position and offset it from the player. It is recommend to refer to the SolverExamples.unity which is located at /MRTK/Examples/Demos/Solvers/Scenes to get stated Solver components.
If I understand you correctly, you want to have a object at a specific distance from the HoloLens 2 at any given time.
So that (for example) a cube is always in the upper right corner of the users view.
If that is the case you can position the desired object as a child to the Main Camera (located under the MixedRealityPlayspace) in the hierarchy view.
I am making a strategy game and I need to have a tool which places the objects above the terrain while I am dragging them in Unity Editor when I work on level design.
Basically I want to get result like here:
https://www.youtube.com/watch?v=YI6F1x4pzpg
but I need it to work before I hit the Play button in Unity Editor.
Here is a tutorial
https://www.youtube.com/watch?v=gLtjPxQxJPk
where the author of it made a tool which snaps the object to the terrain height when a key is pressed. I need the same to happen automatically whenever I place an object over my terrain. And I want my tool to adjust the Y position of the object automatically even while I am dragging it inside of the editor.
Also just to clarify: I don't need grid snapping and I don't need this functionality during the gameplay. I just need to have a tool for my level design work.
Please give me a clue where to start with it.
Thanks!
There is this tag you can apply to classes so they do call their regular events during editor mode already: https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html
A trivial way then would be to apply this to a special class/object which regularly "finds" all objects from the game object hierarchy. Then it shall filter that list for the ones you want to snap to the axis and enforce their Y.
I've spent about 20 minutes searching for this to no avail. All I want to do is create a double sided face for a shop sign for example.
I create a face that sticks out from the building, and I obviously want it double-sided, so I want to simply clone the face and flip the normal.
I know I can do this holding shift and translating the face, but then I have to move it back. I know that you can do this for an object in the edit menu, just selecting clone object, but it doesn't seem to work for sub-objects (ie., faces).
Also, when I searched for how to make a face double-sided, most suggestions were to change the renderer settings to change the face culling, or to apply a double-sided material. But, neither of these methods actually create a new face, do they? For example if I were to export it to my OpenGL project, exporting it wouldn't create the extra face vertices, would it?
Thank you.
Edit: I've been thinking, I know there are many ways to achieve this, I just thought I could detach the face to its own object, clone it in its place, flip the normal, and then attach the two objects to the original again, but the workflow is supposed to be easy.
Thanks.
OK, I've been playing around a bit, and found out that you can
1: Select the face.
2: Click Detach.
3: Select Detach As Clone.
4: Select Detach As Element if you want it to stay in the same object.
How can i make an image to randomly appear while in-game in Unity3D ? It will serve as my popup advertisements for my game. I want to have ads without using AdMobs or any other plugins.
Depending on how you plan to display your images. You could write a script to randomly Enable a GUI Image, then have the GUI Image become disables after a specified time is over or by a button click (like a "X" symbol or close button).
My recommendation would be some mix of the following:
Create an UI Image GameObject. Use this as the main Advertisement GameObject.
Create a script to set this gameobject active/inactive randomly throughout the game. Place this script on an object in the hierarchy that will exist throughout the game.
Create a script that will be your advertisement handler. Attach this to your UI GameObject. In this you can create some sort of structure to hold different ads or however you plan to populate the ads. Then you can customize the way the ads will be displayed. Will it be random? Will it happen sequentially? Are there different types of ads?
Create logic to disable the gameobject based on a timer or by way of a close button.
If you get around to coding and have trouble, then please feel free to ask about the coding. Also, check out the Unity Forums for questions specific to Unity.