- Home /
Can an object to transfer to another as it increases your speed?
Hi everyone! I´m creating a basic pong to understand the bases of unity. My question is:
At the moment the ball collides with the player (object), this increase your speed, but there comes a time when the very is very fast and the ball tranfer the body object instead of bouncing, so Can the speed transfer to the object or do I have a collision error?
How can I make the ball bounce?
This is start metod:
public void Start()
{
Time.timeScale = 1f;
vel = 1f;
panel.gameObject.SetActive(false);
gol = GetComponent<Rigidbody>();
posbola1 = transform.position;
gol.velocity = new Vector3(x * vel, 0, z * vel);
}
increase the speed:
private void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag== "raya") {
vel = vel +0.5f ;
gol.velocity = gol.velocity * vel;
}
I hope you can help me. Thank you!
Have you tried playing with the mass values of the rigidbodies? If i understand correctly, your pad is starting to move from the collision when your ball hits it at very high speed. So you could set the pad mass high and the ball mass low. Also, because pong pads only move in 1 dimension, maybe setting a constraint on the other dimensions might help.
@metalted
Yes I´m using rigibodies in both bodies, the mass of ball is much less than the body it collides. In fact I´m using two dimensions, in this case is X, Z. Y is value 0 I don´t use the third dimension
Answer by harethl1s · Mar 18, 2020 at 06:27 AM
The issue is in the tag comparison change it To collision.gameObject.CompareTag("raya")
Also add this code inside the tag comparison code for collision Debug.log("collider");
And run it if it you see debug.log works then it's finally works and you can remove it