How to move forward with rotationg head - unity3d

I am trying to move forward like this
float speed = 40;
this.transform.Translate(0,0,speed/50);
It works well when character's face is looking horizontally(y=0)
However when character's face is looking down,
Somehow, It goes down through the terrain.
Is there any good way to move horizontally even character's face is looking down??

If the GameObject the script is attached to is passing through the terrain (to find out look in the scene view with the object selected and see if its position is inside the terrain):
transform.Translate moves the position of a GameObject in the direction specified even if there is an object with a collider in the way such as terrain.
If you want to move an object with collision detection you should think about using a Rigidbody or CharacterController.
If the camera is seeing through the terrain even though the camera is not inside the terrain (to find out look in the scene view with the camera selected and see if its position is inside the terrain):
It is possible that the value of the camera's near clipping plane is too large. The camera's clipping planes tell Unity at what distances to start and stop rendering geometry. The far clipping plane tells Unity at what distance away from the camera to stop rendering geometry and the near clipping plane tells Unity at what distance from the camera to start rendering geometry. Any geometry within the two values is rendered and any geometry outside the two values is not. To stop the camera seeing through the terrain you could try lowering the value of the near clipping plane, to have geometry closer to the camera rendered or move the camera further away from the terrain.

Related

Objects disappear at certain angles

So I made a water shader and for some reason in-game, the object disappears at certain camera angles. the material is also flipping the plane 90 degrees when i place it on an object
ShaderGraph
ShaderGraph
FlippedPlaneProBuilder
VideoOfError
I tried changing the alpha but that had no effect
I'd wager that your plane is moving into the near-clip plane of the camera. Anything that is not within the camera's viewable frustum is clipped away (not rendered).
read more here

Unity 2D: Alter sprite anchor point

I've got a plain 2D Capsule Sprite. I want it to rotate around a specific point instead of its very centre. In other programs, this point is called the anchor point. For context, I'm making a paddle for my 2D pinball game so obviously the paddle needs to move when you press a button, but I can't have it moving around its very centre... Well, I could but I don't want to.
So my questions are:
Is anchor point the correct term for Unity?
Can this be altered/moved and how?
So, I ended up getting an idea from a friend who does this stuff too.
I made an empty game object. Made it the parent of my paddle. Moved the paddle to the point of the game object where I want the paddle to rotate around, and now when I rotate the game object, it rotates the paddle around the pivot point that I want it to have.
Image of paddle, arrow pointing to the empty game object
Edit: Just works using UI components within a canvas
You can use the Anchor presets of the Rect Transform. Or define the Min/Max values for x/y coordinates in Anchors Property.

How to determine when player (cylinder) has moved above a plane in unity 3D?

I am making a delivery game and temporarily designed my game so that the player who is a cylinder at the moment has to locate the delivery location which is a flat plane and move onto it in order to deliver the objects.
I have tried adding a 2d box collider to the plane to detect when the player collides with the plane but the collider only works on the x,y axis and i am not able to rotate it 90 degrees.
So my question is what is the best way to determine when the player has moved above the plane?
Here is a picture to demonstrate what i mean:
Before moving onto plane
How to i detect this:
Player is on top of plane
First, make sure at least one of the objects has a rigid-body component. If you are using a character controller to control your player, add the rigid body to the plane. If you don't want the rigid body to affect the plane, just freeze all the position and rotation constraints. Next, make sure both of the objects have a 3D collider, not 2D. Your game is 3D and needs 3D colliders. 2D is for 2D games such as sprites. (I recommend a cylinder collider for the player and a box collider for the plane.) Make sure the plane's collider "isTrigger" is enabled. This should work for you to detect the collision.

How to make Quads flush with each other

I'm making a game where I move a red cube across a plane with arrow keys (I am setting the velocity in order to get a constant speed) Here is a preview:
game
Currently, I am just using a plane with a grid material/texture. However, I wanted to change one of the tiles in this grid to a different color and detect when my cube passes over it.
My idea was to simply replace the plane with a bunch of quads. However, when I do that and try to navigate my cube across the quads, it seems to collide with the side of the quad and flip up, despite the fact that they are all at the same height and positioned right next to each other.
Is there a way to make the quads flush so when I push my cube over it, it won't collide with the side of the quads? Is there a better way to create this behavior?
You can disable colliders at this quads and add invisible big plane with collider

How can I rotate an object based on an angle?

I am working in Unity3D and I was wondering how I would rotate a cube based on the angle between the cube and the mouse position. With that I don't mean the mouse position in world space but in pixels.
Here are some pages that'll lead you to your answer:
Input.mousePosition This also includes an example of how to turn screen coordinates into a ray in world coordinates. If you know how far away from the camera you want your point, check out ScreenToWorldPoint for a point instead of a ray.
transform.Rotate To perform a rotation.
The rest of your question is kinda vague--rotating "based on" the angle between cube and mouse position could mean a lot of things. You shouldn't need much more information than this though!