Home > Software engineering >  How to increase the size of main player in unity
How to increase the size of main player in unity

Time:10-28

I am learning Unity and C# and I am trying to build a game like roll a ball but what I am trying to achieve is that every time ball hits a cube, 10 points are increased and the size of the ball increases. I was able to display the score but have no idea how can increase the size of the ball and also the distance of the camera from the ball.

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

public class increasingPoints : MonoBehaviour
{
    Vector3 temp;


    void OnCollisionEnter(Collision collision)
    {
        if(collision.transform.name == "MyPlayer")
        {
            score.Score  = 10;
            Debug.Log("Ball Collided");
            Destroy(gameObject);
           
        }
    }
}

This is what I have till now which is helping me increase the score when the ball collides. How do I increase the size of my ball and distance of the camera?

CodePudding user response:

To increase the size of the ball:


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

public class increasingPoints : MonoBehaviour
{
    Vector3 temp;


    void OnCollisionEnter(Collision collision)
    {
        if(collision.transform.name == "MyPlayer")
        {
            score.Score  = 10;
            Debug.Log("Ball Collided");
            collision.transform.localScale *= 1.1f;
            Destroy(gameObject);
           
        }
    }
}

I can't modify your camera location without knowing how its set up.

  • Related