Hello i have 2D game in Unity, there are two walls.. one on right side and one on the left. The player Must pass from one side to another just click and a character move on the other side.. on the walls is obstacles..how i can script this?
I think your description is a bit too vague. Tall walls, short walls? How does the player move, jumping over the walls, passing through them? From one side of the right wall to the other side of the right wall?
I have the background: And the player must jumping from right wall to left wall because on the right is some obstacle.. and when is obstacle on left, he must jump to the right CAN YOU HELP ME?
Hi, I dont think we can quite understand what you would like to achieve.. The instructions are a bit unclear.
I need script this: When player touch on the screen on mobile, the stickman moves from the right wall to left wall, or from the left wall to right wall.
always assume that the person you are talking to is a child. now, do you think an eight year old could understand your question? your background image doesn't really help at all. alright, let's take this one step at a time. in order for you to move your character, use transform.Translate. play with that one first.
do you using physic2d ? If so, make tags LeftWall and RightWall for walls. Code (CSharp): using UnityEngine; using System.Collections; public class Jump : MonoBehaviour { bool isLeft; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if ( Input.GetKeyDown (KeyCode.Space) && isLeft) rigidbody2D.velocity = new Vector2 (10, 3); if ( Input.GetKeyDown (KeyCode.Space) && !isLeft) rigidbody2D.velocity = new Vector2 (-10, 3); } void OnCollisionEnter2D (Collision2D other) { if (other.gameObject.tag == "LeftWall") { rigidbody2D.gravityScale = 0; rigidbody2D.velocity = new Vector2 (0, 0); isLeft = true; } if (other.gameObject.tag == "RightWall") { rigidbody2D.gravityScale = 0; rigidbody2D.velocity = new Vector2 (0, 0); isLeft = false; } } } try to run walls in assets. I dont think its the best way, but its one way 2. you can just animate it animator. And then switch animationen left-right, right-left 3. or move between two points with lerp