I am learning to code and make games in unity, so I am very much a beginner. I made a little square jumping game in 2D that can jump, and move Left and Right. But for some reason the physics make it so that my square can flip over and it wont jump after it does. I have a GameObject that is named feetPos so that my square can jump, but as soon as the square flips over it wont jump again. is there any way to fix this? Or make my square not flip over?
(I don't know how to put link of the code)
Not exactly sure if this would help your specific issue. But to stop rotation of your square entirely once it jumps you could:
go to the Rigidbody2D Component for your square,
and then navigate to Constraints:
then selecting the 'Freeze Rotation' option for the z-axis of your square
you can find out more about RigidBody2D rotation on the unity manual docs for the different types of body types your Rigidbody2d component may use:
Related
the question is quite simple. I have this platform and I do not want the player to collide with it when it jumps on the side or under it. In my Tilemap I have already added a composite collider 2D to the collider, so it doesn't separate each tile into a different collider.
As you can see, there are 2 tilesets but 1 collider thanks to the composite collider 2D. I have also changed the physics of this tileset, which is why the collider is so small (which is intended) so that the player can walk under it with no issues: Ej
However, when I jump to try to reach it by side, it does collide, ignoring the side arc function. I have never used a side arc, so I'm not sure if it should be done like this.
This is what happens instead of going through the platform it collides with it ... I thought Side Arc would let me go through the platform if I go by the sides, which is what the logic of the statement of a side arc would do but I guess I was wrong.
it gets stuck instead of going through, so what am I missing or doing wrong ?
I know I could simply hardcode it by making it trigger and when the "ground" collider attached to my pj touch it remove the trigger but I wanted to know if it was possible without that.
When i Click on the play button my Spire flies off into the ceiling of my map.
I have a simple png as a sprite in unity.
I use a tilemap for the level i made which has a TilemapCollider2D and a BoxCollider2D.
https://imgur.com/2tggchP <- photo of what is happening.
My character has a BoxCollider2D and a Rigidbody2D.
I'm making a side scroller in case that is necessary to know.
The gravity and stuff for the character is normal and so is the mass.
My character(s) should just stay on the ground.
I'm not exactly sure if the grey part of the backroud is the object that has a BoxCollider2D but if it does that that's your issue.
You can't have two BoxColliders overlapping each other otherwise you'll get what your seeing now, one shooting up.
I would suggest removing the BoxCollider2D on the tilemap (if that's possible) and maybe just having a BoxCollider2D on that floor in the picture.
If my answer didn't help or wasn't good enough I would be happy to help you further, just reply to this. :)
First of all, I'm a german so please forgive me my (maybe bad) English.
I'm programming a 2.5d Puzzle Jump'n'Run like Trine and of course, you can play an archer/ranger/etc. And you shoot an arrow by clicking on the screen and the archer will rotate his upper body, his arms with the bow and the head so that the bow is looking at the Point where you clicked on the screen.
Here is the problem: How can I rotate or transform the mesh of my character, that he/she is looking at the point because when I just rotate the element by script, the animator sets the Rotation to the default Rotation changes of the Animation.
Is there any way to handle this or do you know of another method?
I want to move a cube by making it roll on it's edges. The cube will be standing on a x-z grid and each movement it takes will make it stand on a different square of the grid.
The player will controll the movement and will only be able to make the cube roll on one direction at a time (left, right, forward or back), but the cube must always stand exactly on top of one of the grid's squares.
I don't think applying a force to the cube will help cause it could move it a little bit too much or too little. I want to achieve something like this: https://www.youtube.com/watch?v=yaAIUYuNi84 but only on the x-z plane. Notice how on each corner the cube can stop and change direction with ease, because it never moves too much or too little.
Any ideas on how to approach this?
If you are new to the Unity it will be useless to trowing you a bunch of codes so i am telling you the way of doing it so you can implement your own codes.
You can create 4 empty game object which will always follow the cube on the floor and when you want to roll the cube you will rotate the cube around the empty objects.
You can find the codes for following the cube and rotating the cube on youtube, and for the starters searching is allways good.
So i hope you can manage it out, if you cant please write me again where did you stuck and i will be happy to answer you :)
I'm making a fps game and I want my character's arms to rotate up and down depending where the cursor/camera is pointing at. The character already rotates when I turn left or right. Hopefully someone can answer my question. I'm new to Unity and I'm still learning how to code in C#.
For top and bottom rotation, create an animation for top aim, eye level aim and feet aim. send the value of your rotation to animator controller and animate according to it.