I have a problem with a flashlight attached to first-person character.
The problem is that whenever I rotate my character more than 180 degrees, my spotlight goes dark. When I rotate back the spotlight is OK again. But it seems to me like there is an "invisible border" moving with the character and blocking the light after the certain rotation.
To make it even worse this is only with landscape and not static meshes, which are lighted normally. So is that problem with the first-person character or some landscape lightmass or whatever?
I have attached some screenshotsenter image description here for you to imagine.
I appreciate any help.
Figured out that this was not a problem of the character, but of the material itself. The problem is fixed now.
Related
Unity 2021.3.16f1/URP 12.1.8
I've just started with Unity a few weeks ago and am still getting to grips with how everything works. So please don't assume I know everything there is to know about Unity. Treat me as a n00b. 😉
I'm building a VR game for the Quest/Quest2. I have a scene with a keypad on a wall. When the payer "clicks" it, I want the scene to go dark, and a large version of the (3D) keypad to appear with which he can then interact (enter numbers). This keypad must always stay in the middle of his view.
What I did was create a canvas, and added a black plane with 50% transparency and the large version of the keypad. I've set up the canvas as follows:
This works somewhat. It has two major disadvantages: 1) the keypad is receiving lighting from the scene while I want it to be fully lit all the time, and 2) the canvas and all its children clip through walls and objects while I always want it to be rendered in front of everything else (yes I know this will mess with your depth perception in VR, but I already have a solution for that).
So the next thing I tried, was stacking cameras. I created a second camera and set is as an overlay camera. I also set its Culling Mask to UI:
Additionally, I added the new camera to my Main Camera as a stacked camera. I changed the Culling Mask of the Main Camera to everything but UI:
This works they way I want it but at a cost: performance takes a huge hit. My frame rate actually halved. I read everywhere that this is a known problem for mobile devices (which the Quest really is).
Another solution I read about, is using RenderObjects. But I can't really find how to use this. I'm not even sure it really is a solution to what I'm trying to achieve.
So can anyone tell me how I should go about doing this? Thanks in advance!
The solution of lighting is the that you can setup the layer of your keyboard to something like "Keyboard"
And in Directional Light you can uncheck keyboard layer.
The solution of second problem is that you can change culling mask of camera on Run Time Like this:
~(1 << LayerMask.NameToLayer("Keyboard"))
renders everything except the transparent layer.
1 << LayerMask.NameToLayer("Keyboard")
renders only the transparent layer.
NOTE: You can set your own layer and check/uncheck what you want it is just a example
I created a turret that auto-shoots bullets , fairly simple and not complex, but I have some visual problems. Like in the Editor while Play mode is active the bullet spawn and is visible , but when I go in that place in play mode the bullet is invisible (the bullet applies the damage to the Player but it is not here).
Some footage of the problem: https://gyazo.com/899f4c60f7d3e0fc943c104bba7c2831
There are 2 possible answers:
set the canvas to Screen Space - Camera, and set the Render Camera to Main Camera.
linke to the full artical
fix the possition of the srite and the canvas
link to the full artical
Thank you for all the help!
IT WORKED!
I find out that , my turret Z's was like -68 and the camera was like -10, and i randomly entered the 3D View of my scene and i noticed that my Turret was like 10 kilometers away from the actual position from the editor!
The first problem happen when I'm playing a stand up animation took from mixamo.com including a character from mixamo. The animation is working fine and the character does stand up but in the end when the animation finish some parts of the character are rotated not to 0,0,0 so the character seems a but standing on the side. Maybe this is how it should be but I wonder if there is any way to make the character standing right like 0,0,0 ?
The mixamo character is Medea. And this is a screenshot of it before running the game :
And this is the character after the animation ended :
When you arel ooking on the left scene view window the character seems to be standing fine also on the right in the Inspector the rotation is fine 0,0,0
But when you are looking on the left on the game view window you see that the view rotation is not like 0,0,0
When I'm looking on some of the mixamo character childs like the mixamorig:Head or the neck and other childs some of them the rotation is not 0,0,0 and if I will play with it and change some of them to 0,0,0 then the character will looks like standing fine looking forward straight :
I tried now and changing only the head rotation to 0,0,0 make it looks fine.
The problem is how to change the head to 0,0,0 when the animation end ? It will looks bad like the head is turning strange at once to 0,0,0
My problem is not how to change the head rotation at the end of the animation but that it will look bad that the head is suddenly change rotation.
Seems like you're building a first-person game and using the ready to use animations from Mixamo. If this is the case, don't attach the camera on the head. Head will move based on the animation which is not in your control.
If you want to give a realistic feeling for cutscenes for example, at the beginning of the game, the character is standing up, etc., then you can add 2 cameras, one to the character, and a second one is on the head. So during the cutscenes, you can use the head-mounted camera and for the gameplay, you can switch to the normal camera.
You can also use just one camera mounted on the character (not the head) and try to update the position of the camera based on the position of the head until the cutscene ends, then set the camera to the default position (you can set an animation event at the end of the animation to do that).
I'm having an issue where my character is facing 90 degrees away from the (first person) camera. So when I move the character, the model is turned 90 degrees to the right instead of facing forward. (Pic 1)
Since the camera is a child of the player, if I rotate the character -90 degrees, the camera rotates with it. If I rotate my camera back 90 degrees, the controls get messed up (the W to go forward becomes W to go right, etc.) (Pic 2)
Is there anything I can do to either change the default rotation of the
For reference, I am using this FP Controller torah horse(.)com(/)First-Person-Drifter-Controller-for-Unity3d-1 (that uses a cylinder, so doesn't have the same rotation issue)
I'd advise you to put a script on the Camera instead of making it a child of the player. This gives you more freedom in how the Camera behaves.
Actually, looking at your pictures again... Why not just set the Camera behind the player correctly, instead of rotating the player. When you have the Camera as s child it will be responsive to the parents transform, but it wont mimic. It will follow with the same offset as it starts with. So instead of rotating the player, which messes up the controls, simply put the Camera where you want it from the start.
I'm trying to create a chipmunk space with a bouncing ball.(Example seen here)
Currently my device is running in Landscape mode. So according to cocos2D everything is all right. When adding Sprites they orient to landscape mode.
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
The only problem is that the device orientation is screwed up when using chipmunk right now. When tilting the ipad towards the upper-left corner, my 'bouncing ball' moves towards the upper-right corner.
Is there a way to rotate a chipmunk space manually?
Or is there some other way to set rotation within a chipmunk space?
It sounds like a simple sign issue. I assume the balls are moved by applying a force to them. So instead of applying a positive force like (10, 0) apply a negative force (-10, 0) when moving the balls in one direction, and do the reverse in the other (eg multiply x coordinate forces by -1). Chipmunk doesn't care or know about device orientation, it just moves objects according to forces and gravity.