- Home /
Sphere with constant speed and bouncing attribute.
Hi
I would like to make sphere with constant speed and bouncing attribute in 2d game. I've 3D scene with camera from the top (like in the picture below). I can't find out how to make sphere to bouncing from triangles or other figures, with only constant speed in many directions. Is there any way to solve this?
Answer by toddisarockstar · May 11, 2015 at 06:17 AM
this code isnt complete. you would have to figure out the details yourself. i would get the rotation of the object that the ball collides with and add it to the ball on collistion.
var B :GameObject;
function Update(){
transform.Translate(Vector3.forward * Time.deltaTime);}
function OnCollisionEnter(bumped : Collision) {
b = bumped.collider.gameObject;
transform.rotation= b.transform.rotation;}
play with the the math to add or subtract or multiply between the two object's angles to get the result you are looking for.
Your answer
Follow this Question
Related Questions
2D on 3D collision 2 Answers
How do I set a sprite to a sphere? 0 Answers
Why do my objects keep changing speed? 1 Answer