At the moment I've set up a dual camera scene in Unity. I've created an empty game object for my camera's to inherit from and attached some of the first person controller scripts to this empty game object.
When I run the program in the editor, it runs fine. When I build the project, the game crashes and my camera objects fall through the ground. I've never experienced something like this before in Unity. Attached is a copy of my my current fps set up values.
In the picture, you will see that I have turned gravity off (set it to 0), yet it still falls down when I run the built program.
Has anyone ever come across something like this before? I've spent all day trying to fix this, but I'm getting no where.
I experienced such an issue when my parent object (I usually use capsules to "carry" the camera as the players head like 1.70m above the ground) is set to low ... what happens if you move your camera-guy together with the game object one meter upwards? (so that he falls down a bit against the surface when you start).
Maybe there is a difference in some relations between editor-build and release-build.
Or, in case this isn't the solution, check the spatial positions of your involved objects again. Falling through a terrain is often produced by misplaced reference objects. (I sometimes hung a carrier object under a camera instead of hanging the camera under a carrier object.)
As you say that it works in the editor-build i assume that you have activated collision for the relevant objects.
Related
I am building an app for the HoloLens gen 1 device using Unity 2018.3.13f and MRTK V2 RC1. I got a simple AR design with 2 text objects and 1 rawimage object. After building the project and deploying it to the HoloLens the AR objects ends up behind the spatial mesh (you know all those spatial triangles), but I want all the objects to be in front of the wall.
How do I accomplish this?
The canvas is set to be on the main camera
I have the original settings for the DefaultMixedRealityconfiguraitonProfile if there is something there that needs to be changed.
This is how it looks through the hololens with the app when it does not show the mesh of the wall (sorry for the bad quality)
and this is how it looks when it falls behind the mesh
Do I need to add some mesh renderer or something on the MainCamera to make this possible?
Any help is appreciated, thanks!
I don't believe that the MRTKv2 as of 2019/5/9 has code that will auto-ensure that a specific object is positioned in between the camera and other arbitrary meshes and colliders (i.e. the spatial awareness is one such mesh, though you could imagine just having an arbitrary box or plane in the scene that would occlude that object, in which case, maybe you'd want your "in between" object to stay in between both those two types of potentially occluding things).
There used to be a script in the HTK called Tagalong.cs that would do something like this by doing raycasts from the camera to collidable object:
https://github.com/microsoft/MixedRealityToolkit-Unity/blob/htk_release/Assets/HoloToolkit/Utilities/Scripts/Tagalong.cs
This single large script I think got broken up into smaller scripts (i.e. specific behaviors in the solvers here:)
https://github.com/microsoft/MixedRealityToolkit-Unity/tree/mrtk_release/Assets/MixedRealityToolkit.SDK/Features/Utilities/Solvers
However, from what I can tell, the specific interaction of "keep things automatically between the camera and whatever collidable object" wasn't preserved. Someone else can correct me here if I'm wrong, it looks like this wasn't a behavior that got preserved in V2.
Going forward, there are a couple of possibilities:
1) Probably file an issue on Github here (https://github.com/microsoft/MixedRealityToolkit-Unity/issues) to request this feature be ported over.
2) Use the code in Tagalong.cs to add your own solver that would accomplish this (i.e. the code looks to be all there, there's just some work needed to get done to reorder it to handle what you want)
If you use a sprite renderer, set order in layer (into 0 or -1).
If you use a mesh renderer, try to deactivate dynamic occluded.
Try to change the hierarchy of the sorting layers under Edit-> Project Settings -> Sorting Layers
I'm still pretty fresh to the Unity 3D world. I'm trying to get an animation on two children of an object (a door that has the exterior facing outward and a door facing inward). Maybe I'm approaching this the wrong way? See below:
Is there a way in which by pressing one key,i can get both "open" animations for both the inward and outward facing doors to play at the same time? Note: I originally created this FBX in Blender.
I am trying to use the HTC Vive controller to pick up and throw objects in Unity. The idea is that you get the controller close enough to the object to touch it, hold the trigger to pick it up, and release the trigger while making a throwing motion to throw it. I have a script and box collider on the controller, and rigidbodies and box colliders on the objects. If I try to pick up an object, it kind of shakes and bounces, but uncontrollably. I am also having the issue where the objects bounce around randomly in the environment instead of being still. Any suggestions?
Check this Tutorials. It's good, a bit old but for sure will get you on track and show you how it's done.
Video Tutorial - Click me
I'm actually working on a board game using unity. It's a board game where players have to connect two opposites borders by claiming empty hexagonal cases. Borders are assigned to players at the beginning.
I chose to represent my empty cases with gems, white when unclaimed, and red or blue for players. So I made a single prefab for all gems.
To check connections between gems themselves and with borders, I assigned to them slightly bigger box colliders so they are colliding (trigger) with other objects, so I can detect if a claimed gem is connected (directly or not) to a border. I wrote this code generically as gems are one single prefab, naively thinking that every entity would run its own version of the script.. But that's not the case.
So I'm looking for an alternative way to detect connections with borders, but still generically, as the size of the board is variable.
Thanks in advance !
Your problem is closely related on how you break your game in game objects and components on Unity3D.
First of all, use scripts to define components. For example your gems could have a script that contains data related to its state (your white, red and blue gems meaning empty, playerA and playerB).
You will probably need a game object (normally called a GameManager) to handle all behavior related to game rules like which player is playing, if a player can pick a specific gem and if a player won the game. Depending on the game complexity is a good idea to also have a game object with a component (script) to keep your board state, instead of simply getting it from the gems objects Transform component.
After you have structured your game you do not need colliders to detect connections. Every time you have to check for connections, just iterate over your gems or use your board state object.
Edit:
References to help you develop your game:
How do I represent a hextile/hex grid in memory?
Creating a holder for game level for simple board tile based game.
creating 2d table\chess board\2d array
This question is going to sound odd because I really don't understand how this could be possible but here goes. I have some collision code for a 2D game of mine which works perfectly fine on Windows, Xbox, WP7, WP8. But for some odd reason the exact same code does not work when I run my game as a Windows 8 Metro App. What's even weirder is, the code works when I run the same project on my Surface but when I run it on my PC the bullets just go straight through the enemy. I don't think posting the code would be of any use since the code is identical where ever I use it and KNOW for a fact it works. If anyone knows how this is even possible please let me know. If you want me to post the code then let me know.
I'll explain a bit of what the code is doing:
Loops through all the player's bullets
Loops through all the enemies
If rectangle collision takes place
If per pixel collision takes place
Kill enemy, remove bullet etc.
The game runs fine as an XNA game on my PC which is the same PC I use to test it as a metro app.
This might be a computer speed problem. Does your game-loop work on a static timer, or do you throw updates/draws as fast as you can? It's possible the bullets aren't colliding because on one update they're in front of the enemy, and on the next they're behind. Try 'widening' the enemies or bullets as a debug - that may fix it. If this is the case, you may have to do some bullet updating within the update to make sure it hits all the locations in-between. and doesn't teleport through the enemies.
If you are using pixel values to test for collision, you may be trying to use DIP (device independent pixels) pixels thinking they are screen location pixels (something new with Metro, in fact, it's the default).
Set your app to run in simulation mode and set the sim's screen resolution to: 1366x768. Does it suddenly work correctly? if so, then it's a DIP issue.
Start here: http://msdn.microsoft.com/en-us/library/windows/desktop/ff684173(v=vs.85).aspx
notice the formula halfway down the page: DIPs = pixels / (DPI/96.0)