Unity localScale problem with character stuck in wall - unity3d

I recently downloaded unity, and I found that the localScale method was a better option for flip a character(especially for the box collider). But when I go close to a wall and turn, my character get stuck in wall. Do Code that I use](https://i.stack.imgur.com/zHuz1.png) have solutions ?Game preview](https://i.stack.imgur.com/C7vfj.png)
I tried to make my wall bouce my character and nothing changed, sometimes he got stuck.

It's easy to solve once you understand the 'base' by which the scale is flipped.
No. 1 and 2 of the uploaded image show the x scale value of 1 and -1 when the reference axis is in the center.
Numbers 3 and 4 are when the reference axis is moved to the (0, 0.5) position of the image center using the sprite editor, and the x scale value is set to 1, -1 in the same way.

I thank you for giving to me the solution to my problem.

Related

Unity some of the object comes with wrong axis from blender fbx file

The problem I have is simple. When I export my file in a blender as fbx and import it to the unity, the objects (or part of the objects for some reason) turn into the wrong axis while it looks ok in both blender and fixes file. I looked at google for this problem. Most of them did not help me. I saw that coding might help. I found a code that can help me which is this:
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
But the problem remains because it changes all of the rotation of the road, so the right roads become wrong while wrong roads become right. Putting this in the necessary planes might work but there are so many planes and I will put more planes in the blender project in the future so it won't help me too much.
I have two options.
Write a code that changes it to the right axis if the plane/object looks at the wrong axis.
Find the right way to import it.
I don't how to do any of the time since I am a beginner. I use Unity 2019.4.33f1 and Blender 2.83. Please help me
https://drive.google.com/drive/folders/13Y-lnccTvNPWPKAT520CCM8u-7MgaXkR?usp=sharing
Thank you
EDIT: I put my blender file to the drive link as well.
EDIT2: I keep editing I know but I realize that I have another problem as well. The problem is that Unity gets my object wrong, for example, I have a half green half red object and I want both colors to be at the +y axis. It makes the red part at -y axis. Here are the pictures: https://drive.google.com/drive/folders/1ob5xdKv0nPHN3TSABHGDVA7inW8vkag6?usp=sharing
How can I fix this :'(
LAST EDIT: I found a way to solve it. I added the same object twice but one of them has a different setting. Assume that rotations are 0 0 0 (x y z respectively) and scales are 1 1 1 (x y z respectively). The second road will be different settings from the first road. Its rotation settings will be 0 0 180 and the scale will be -1 1 1. Of course, I am open to better suggestions but this is the solution I found.
SOLUTION: After a long time later, I finally found the answer. I updated this in case someone needs it later. All I had to do was calculate the normals again and the way we do is, after choosing all of the roads, Edit Mode -> Mesh -> Normals -> Recalculate Inside / Recalculate Outside
Blender uses a left handed coordinate system, where the Z axis points upwards, whereas Unity uses a right handed coordinate system, where the Y axis points upwards. There might be some extensions or packages to keep them the same, however you probably just have to rotate the model in Unity or Blender to fit your needs.

Forward facing vector is a bit offset

I am making an FPS game and I need for the forward facing vector to hit exactly where the crosshair is aiming.
This is my current blueprint.
It takes all references from the camera position where the players head should be. (as it usually is in FPS games).
When "shooting" the vector it is slightly offset though. (pink dot near crosshair)
Things I have tried:
Increasing distance of vector makes the problem go away but it then becomes inconsistent, which means it's a bad solution to the problem :(
Manually changing axis values, but that was also very inconsistent.
Changing between 3 different nodes of taking rotation from the camera, they all (didn't) work the same way :/
Maybe there is an issue of the values that I am taking, although the starting position of the camera seems to be correct.
Thank you for any insight you may have!
Suggested by user Ruzihm the issue was that the crosshair was off-center. My blueprints were actually okay.
So for anyone looking see if your crosshair is in the center.

Deploying to Hololens 2

I opened up a unity project and simply put a cube on the scene view. I then got it to deploy in Visual Studio 2019 without any errors.
When I viewed it in Hololens 2, it shows up as a blank image with no error message to be found anywhere.
Any idea as to what could be happening that would cause this?
Thank you
Since I can't add a comment yet, here's an answer that should be seen as an addition to Hernando - MSFT's answer.
Additionally to the scaling of the cube, it makes sense to position it reasonably. As already mentioned, one unit corresponds to one meter.
In the Inspectorview of the cube, Z is the distance to the camera and X and Y are the horizontal and vertical offsets.
Reasonable values for the mentioned position are X/Y/Z equal to 0/0/0.5 for example. Then the cube should be in front of you after starting the application.
Have you manipulated the cube's Scale property after adding the cube into your scene?
In MR spatial coordinate system, 1 unit = 1 meter, and the default Scale property of the new cube is "1, 1, 1". This means that the cube will be too large to completely block your view, so you can only see a blank.
We recommend that you try to manipulate the cube's Scale property to "0.1, 0.1, 0.1" for testing, if you see any different behavior, please let me know.
I think it can be
your box is too large and near the camera
or the Clear Flags of Camera is Skybox. If so, you can try to use DefaultHololens2ConfiurationProfile

Explanation of how to calculate transforms in Unity

I am getting started with Unity and am just trying to get my head around the units. What are these units? It seems they are their own 'quantity' and to treat 2 units as 2 times the value of 1 unit.
Anyway - I am trying to workout how to optimally calculate transforms to objects sit exactly where I want them to.
In my scene I have a terrain and a cylinder as so:
As you can see my cylinder is floating. I want the cylinder to sit perfectly on top of the terrain.
My terrain is at the following transform: 0,0,0 and scale 0,0,0 (not sure how to tell it's dimensions yet).
My cylinder is part of a new object, as so:
My FirstPersonPlayer is at transform: 85.9,2.165,51.8 and scale 1,1,1. My Cylinder is at 'localposition' 0,0,0 and local scale 1.2,1.8,1.2
Now - the transform of FirstPersonPlayer on the y axis appears to be what I need to correct.
Currently it is set to 2.165 and is floating a bit above the terrain.
Through manually shifting it, around 1.85 looks about right - but I want to know how to calculate that, rather than doing a finger in the air 'that looks about right'.
Can anyone help me? (Before you suggest using gravity etc , I actually am, but don't want the player falling as soon as they start, however slight that may look or feel.
Many thanks,
As per #Nikola Dimitroff the answer is:
You don't have to compute anything, hold Shift + Control and drag the object. Every game engine ever made calls this "Snap to Ground"
I appreciate and agree with the other comments.

transform.Translate not working properly in Unity

I am developing a game in which I want infinity road, So I created 40 instances of the road which I want to repeat again and again.
I am writing the following code to change the position of road that is not visible in the camera now and can be repeated
roadPaths[currentRoad].transform.Translate(Vector3(0,0,startPositionValue));
But I am getting the following log
In the above log you can see when the startPositionValue is 42, currentRoad position becomes 43. Same issue is with other values as well.
A help will be highly appreciated.
Translate is a relative move of the GameObject in three-dimensional space. It literally translates it from the current position by a relative value to a new position that is an offset from the original.
Explicitly setting the Position vector of the GameObject's Transform will set it to an absolute position within the world.
Finally I am able to solve the issue.
The following code work
roadPaths[currentRoad].transform.position=Vector3(0,0,startPositionValue);
I think this is very simple:
transform.Translate(X, Y, Z);
for exemple:
transform.Translate(5 * Time.deltaTime, 0, 0);
//GameObject moves smooth at the positive direction of the X position