not sure if this is right thread to post this but
Started Unity a week ago. Read up some books and tutorials.
Basically I bought some stuff from the asset store and am testing it out atm.
Sometimes my character gets stuck and sometimes it doesnt. When it gets stuck it doesnt move. When I am able to move through it, my character flips itself.
All ground have boxcolliders and so does the player. player also has rigidbody. Here is the script and a video to showcase my problem. Need some helpp !! Thanks
link"
- usingUnityEngine;
- usingSystem.Collections;
- publicclassPlayerMove:MonoBehaviour{
- publicfloat speed =365f;
- publicfloat maxSpeed=5f;
- Rigidbody2D rigid_Player;
- // Use this for initialization
- voidAwake(){
- rigid_Player=GetComponent();
- }
- // Update is called once per frame
- voidFixedUpdate(){
- float x=Input.GetAxisRaw(“Horizontal”);
-
- if(x * rigid_Player.velocity.x < maxSpeed)
-
- rigid_Player.AddForce(Vector2.right * x * maxSpeed);
-
- if(Mathf.Abs(rigid_Player.velocity.x)> maxSpeed)
-
- rigid_Player.velocity =newVector2(Mathf.Sign(rigid_Player.velocity.x)* maxSpeed, rigid_Player.velocity.y);
- }
- }