hello,
I have 2 questions. seemed easier to link them into 1 thread as they are simple fixes that I can’t seem to get right.
BALL CONTROL:
I’m creating a game where you roll a ball from start to finish (basic I know but focusing on learning scripting not gameplay). when the ball rolls around the board and then you stop the joystick, it just stops dead rather than rolling around like a ball naturally would. I feel like I should be using AddForce to make the ball feel more like a ball but can’t seem to find out where to add it in.
my current script is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
protected Joystick joystick;
// Start is called before the first frame update
void Start()
{
joystick = FindObjectOfType<Joystick>();
}
// Update is called once per frame
void Update()
{
var rigidbody = GetComponent<Rigidbody>();
rigidbody.velocity = new Vector3(joystick.Horizontal * 10f,
rigidbody.velocity.y,
joystick.Vertical * 10f);
}
}
SECOND ISSUE:
I also want the ball to slowly scale up in size over the duration of the level. I have it working where it scales using Time.deltaTime but is scaling up too quickly and can’t figure out how to slow it down. can I slow down Time.deltaTime or is there another alternative?
That script is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerGrow : MonoBehaviour
{
Vector3 scale;
void Update()
{
scale = transform.localScale;
scale.x += Time.deltaTime;
scale.y += Time.deltaTime;
scale.z += Time.deltaTime;
transform.localScale = scale;
}
}
thanks in advance!