Saturday, June 18, 2022
HomeGame Developmentunity - collision features not working

unity – collision features not working


I am a newbie at coding and needed to make a fast little program to check my googling abilities up to now. I am making an attempt to make the participant recreation object be given a pace enhance when it collides with the pace recreation object and it would not work (the dice can nonetheless transfer but it surely is not affected when colliding with the pace). under is my participant motion script and my pace energy up script

utilizing System.Collections.Generic;
utilizing UnityEngine;

public class Participant : MonoBehaviour
{
    public float moveSpeed = 10f;
    void Replace()
    {
        Vector3 place = rework.place;
        if (Enter.GetKey("w")){
            place.y += moveSpeed * Time.deltaTime;
        }
        if (Enter.GetKey("s")){
            place.y -= moveSpeed * Time.deltaTime;
        }
        if (Enter.GetKey("d")){
            place.x += moveSpeed * Time.deltaTime;
        }
        if (Enter.GetKey("a")){
            place.x -= moveSpeed * Time.deltaTime;
        }
        rework.place=place;
    }
}

and right here is the facility up script. I used a debug log to determine the place the issue is and its the road beneath the personal void

utilizing UnityEngine;

public class Velocity : MonoBehaviour
{
    public float speedIncrease = 5f;
    personal void OnTriggerEnter2D(Collider2D collision){
        if (collision.tag == "Participant"){
            GameObject participant = collision.gameObject;
            Participant playerScript = participant.GetComponent<Participant>();
            if (playerScript){
                playerScript.moveSpeed += speedIncrease;
            }
        }
    }
}

I come from blender stack change the place we offer all items of information we really feel are related. please let me know if that is not the case right here or I left one thing out

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments