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

Player Denis

This document defines a player script that controls player movement and jumping using input. It attaches and detaches the player from moving platforms on collision.

Uploaded by

eduardojsa.24.07
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)
8 views1 page

Player Denis

This document defines a player script that controls player movement and jumping using input. It attaches and detaches the player from moving platforms on collision.

Uploaded by

eduardojsa.24.07
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;

public class Player : MonoBehaviour


{
public float velocidade;
public Rigidbody2D corpo;
public float pulo;
private void FixedUpdate(){
{

float moveInputup=Input.GetAxisRaw("Horizontal");
corpo.velocity=new Vector2(moveInputup* velocidade,corpo.velocity.y);
}
}
private void Update()
{
if(Input.GetKeyDown(KeyCode.UpArrow)){
corpo.AddForce(Vector2.up * pulo , ForceMode2D.Impulse);
}

}
void OnCollisionEnter2D(Collision2D entrarSair)
{
if (entrarSair.gameObject.CompareTag("PlatMov"))
//if((entrarSair.gameObject.name.Equals("PlatMov")) ||
(entrarSair.gameObject.name.Equals("PlatHorizontal")))
{
this.transform.parent = entrarSair.transform;
}

void OnCollisionExit2D(Collision2D entrarSair)


{
if (entrarSair.gameObject.CompareTag("PlatMov"))
//if((entrarSair.gameObject.name.Equals("PlatVertical")) ||
(entrarSair.gameObject.name.Equals("PlatHorizontal")))
{
this.transform.parent = null;
}

}
}

You might also like