Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity rollaball

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

public class PlayerController : MonoBehaviour
{
    public float speed = 0;

    private Rigidbody rb;

    private float movementX;
    private float movementY;

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

    private void OnMove(InputValue movementValue)
    {
        Vector2 movementVector = movementValue.Get<Vector2>();

        movementX = movementVector.x;
        movementY = movementVector.y;
    }

    private void FixedUpdate()
    {
        Vector3 movement = new Vector3(movementX, 0.0f, movementY);

        rb.AddForce(movement * speed);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("PickUp")) 
        {
            other.gameObject.SetActive(false);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: pick random point inside box collider unity 
Csharp :: join string c# 
Csharp :: how to parse mongo db json in c# 
Csharp :: unity deactivate scripts in list 
Csharp :: request a pricipal permission 
Csharp :: if input.get touch 
Csharp :: unity find all scriptable objects of a type 
Csharp :: disable alt + f4 in c# forms 
Csharp :: toLocalIsoString() vs toIsoString() 
Csharp :: unity easing out 
Csharp :: query associative table ef6 
Csharp :: begininvoke async c# 
Csharp :: c# builder pattern fluent example 
Csharp :: query parameters sending to controller action asp.net core 
Csharp :: tilemap shader 
Csharp :: boxing and unboxing in c# 
Csharp :: check if element in hashset c# 
Csharp :: list with search bar uwp c# 
Csharp :: asp.net core update-database specify environment 
Csharp :: ef core many to many fluent api 
Csharp :: list cast< c# 
Csharp :: oauth API with the Access Token to retrieve some of users information. 
Csharp :: dbset properties 
Csharp :: restrictions 
Csharp :: link list in c# 
Csharp :: entity 
Csharp :: linq while loop in c# 
Csharp :: f sharp global variable 
Csharp :: C# print all properties of an object including children objects 
Csharp :: List of border roleplays roblox 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =