0% found this document useful (0 votes)
5 views1 page

код

Uploaded by

Viyan Viyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

код

Uploaded by

Viyan Viyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class CharacterController : MonoBehaviour


{
Rigidbody2D rb;

public float jumpForce, speed;


public Transform groundCheck;
public LayerMask layerGround;
public float horizontalspeed;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
Input.multiTouchEnabled = true;
}

public void LeftButtonDown()


{
speed = -horizontalspeed;
}

public void RightButtonDown()


{
speed = horizontalspeed;
}

public void Stop()


{
speed = 0;
}

public void Jump()


{
if (Physics2D.OverlapCircle(groundCheck.position, 0.1f, layerGround))
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}

// Update is called once per frame


void FixedUpdate()
{
rb.velocity = new Vector2(speed, rb.velocity.y);
}

You might also like