I'm working on Unity game. It's replica of Fruit Ninja with awesome new features and updated graphics. Game is running fine but when I run it on full screen, Collision detection stops and private void OnTriggerEnter2D(collision2D col) function not called in most of cases. I should mention that collision is detected in some cases (not all).
P.S. Game is working super fine when not in full screen.
Related
I have several shaders that use the Time node to animate certain UI elements for my mobile game.
In certain cases (which I am unable to reproduce), the shaders will be stuck on a specific time and not animate.
For example, a shine shader might be stuck mid-shine.
Some important things to note:
Time.timeScale is 1 - all my tweens using scaled delta time are working correctly
When this happens all shaders using the time node in the active scene will "freeze in time"
This only reproduces on actual Android devices (iOS untested)
All parameters affecting time in said shaders are positive, valid numbers
There are no errors or warnings
When I transition from my main menu scene to the game scene, time based shaders will work correctly - when I come back to the main scene, it will reproduce again (obviously it's something specifically there)
Running on Unity 2019.4.11f1 with URP & Shader Graph 7.5.1, but it did reproduce in older versions of Unity/URP as well
Sample shader - The preview actually looks exactly like the issue as it will appear in game when frozen:
For any lost souls who stumble upon this issue (although I doubt it's by design as it seems like a bug).
The problem is that time isn't updated in shaders in scenes without a camera.
The camera doesn't have to render anything; it just needs to exist.
My main menu is pure UI elements and had no camera; adding a camera to the scene fixed the issue.
It is important to note that this behavior only happens once you build to an Android device; not sure if it reproduces on other platforms.
I'm trying to add PUN2 support to a simple Oculus starter scene (cubes on a table). I was able to run the official Avatar synchronization on top of my basic Photon2 setup.
This is the current sequence:
Player 1 ( P1 - the one using Quest) creates the room and joins it
Player 2 (P2 - the one using Unity Player) joins the room
Player 1 grabs a cube and moves it around
P2 sees the cube moving normally if P1 just drags it horizontally, but if he tries to lift it from the table the cube seems acting crazy from P2 point of view.
It looks like the cube fights with gravity but I'm not totally sure what is going on. You can see an example in this video where there is an alternation between horizontal drag and lifting from the table: https://gofile.io/?c=A9PN41
If I disable gravity on the cube it seems working fine (although the interpolation a bit slow compared to how P1 is moving the object): https://gofile.io/?c=jM4qEE
The point is that I cannot have cubes flying around the scene :)
Using Unity 2019.1 / PUN2 / Oculus Quest
For the records, I found out what is the problem but still working on a complete solution. When P1 manipulates an object (kept in sync across clients using Photon Transform View), P2 sees the cube trying to synchronize its position/rotation while fighting against gravity (creating that weird jumpy behavior).
After an extensive I research I found out a possible approach which could solve the problem:
Add a Photon Rigid Body View (sync velocity and angular velocity)
Add an RPC (activated during manipulation) which:
Disables gravity
Enables isKinematic
Transfer ownership to the Player which is manipulating the object.
This needs to be fully tested on both clients (Master/Normal), but so far the results seem promising.
I'm using Unity3D 5.3 version. I'm working on a 2D "Endless running" game. It's working normally on PC. But when I compile it to my phone, all of my gameobjects are shaking when they are moving. Gameobjects are in a respawn loop. I'm increasing my Camera's transform position x. So when my camera is in action, all of the other objects look like they are shaking a lot and my game is working slowly on my phone as a result. I tried to play my game at Samsung, on discovery phones. It's working normally on some of them. But even on some Samsung devices it's still shaking. So i don't understand what the problem is. Can you help me with this?
One thing you can do is start optimising, if you have a game that is either finished or close to it. If you open the profiler, click "Deep Profile" and then run it in the editor on your PC, you'll get a very detailed breakdown of what is using the most resources within your game. Generally it's something like draw calls or the physics engine doing unnecessary work.
Another thing that might help is to use Time.deltaTime, if you aren't already. If the script that increases the transform doesn't multiply the increase by Time.deltaTime, then you're moving your camera by an amount per frame rather than per second, which means that if you have any framerate drops for any reason, the camera will move a smaller distance and that could be throwing out some of your other calculations. Using Time.deltaTime won't improve your framerate, but it will make your game framerate independant, which is very important.
I am in the process of putting together an app using the Google Cardboard SDK. The user will be able to use the app with or without cardboard. So, there is a switch button inside the app, that activates and deactivates stereo rendering.
The app also uses the Vuforia SDK to track image targets. If a specific target is recognized, some 3D objects above the target and a particle system starts to emit particles.
Everything works fine in non-stereo mode. Particles are emitted and falling correctly as intended. They should simulate snow. Also if the user turns the image target to an angle, the 3D objects above fall down.
When switching to stereo mode, the physics are messed up completely. The snow particles are not falling anymore, they seem to "teleport" around the screen. Also the 3D objects do fall upwards, with a really heavy negative gravity. Timescale seems multiplied several times, but is not - I double checked that. Gravity also does not change when switching between non-stereo and stereo rendering.
Everything works fine in Unity Editor in moth modes. It only appears on the device, which is an iPhone 5.
Cardboard SDK is version 0.52, which is the newest.
Unity is version 5.3.1.
Vuforia is 5.0.6, which is not the newest, but release notes do not indicate a fix concerning physics. Will update it anyway as a next step.
Vuforia is 5.0.10, which is the latest version.
I double checked gravity and timescale, which are not changing when switching between modes. I have a hard time figuring out what might cause the physics to mess up.
EDIT:
I did some further investigations. I made me a little gizmo sitting always in front of the camera but getting the rotation of the Unity world space axes, so I know the 3D-world is oriented in relation to the camera. And it turns out, that when in VR mode with the Google cardboard camera system, the world does spin around the camera heavily. I managed to hold the test device in a way, so it is slowing down and almost freezing, but I have no explanation for the effect yet.
I managed to get my setup right again. Unfortunately I did not find the source of the weird behavior. But By deleting the Vuforia Prefab and the Cardboard Prefab and adding them again to the scene, the problem was solved.
I have a simple Surface 2.0 (PixelSense) application that sends UDP messages to my Unity3D game when there are touch events since Unity doesn't support .NET 4. When I run the game in the Unity editor everything works fine, but when I run the actual Unity build the game freezes unless I move the mouse (keyboard input doesn't unfreeze it). Once it unfreezes, all the updates happen at once.
I also tried running a simple unity build with a sprite that translates in the X axis and starts over once it's not being rendered (does not receive UDP messages). This build runs at the same time as the surface app so it's also running in the background and it also freezes unless I move my mouse so I don't think it's a networking issue.
Run In Background is checked and I also have it in the script.
private void Awake()
{
Application.runInBackground = true;
}
Visible in background is also checked in the Player Settings.
I run the game windowed at full resolution.
Any ideas about this problem?