martes, 20 de septiembre de 2022

C#Unity aplicando fuerzas dos ejemplos;

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

public class MASARRIBAMAS : MonoBehaviour
{


    [SerializeField]

    private float fuerza;

    [SerializeField]

    private float aceleracion;


    private Rigidbody rb;



    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
       // rb.AddForce(transform.forward * aceleracion, ForceMode.Acceleration);
        rb.AddForce(transform.up * aceleracion, ForceMode.Acceleration);
    }
}

--------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------

ejemplo 2

-------------------------------------------------------------------------------------------------

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

public class ARRIBA : MonoBehaviour
{

   
    [SerializeField]

    private float fuerza;

    [SerializeField]

    private float aceleracion;


    private Rigidbody rb;



    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        rb.AddForce(transform.forward * aceleracion, ForceMode.Acceleration);
    }
}

No hay comentarios:

Publicar un comentario