- Home /
Question by
Mobile_Coder · Dec 16, 2016 at 08:38 AM ·
rigidbodytransformtransform.rotationtransform.rotatepong
transform.Rotate slows down my moving cube
Hello,
i am currently developing a "Pong" game with a cube as Gameball. Without rotation of the "ball" everything is fine, now I added Rotation with
GetComponent().transform.Rotate(20,-5,0);
My problem is, that the "ball" is now slowing down due to the added rotation.
How can I fix this? I don't want the velocity in x and y direction to be affected from the rotation.
this is my code for the ball Script in c#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ball : MonoBehaviour {
float sx;
float sy;
// Use this for initialization
void Awake () {
sx = Random.Range(0, 2) == 0 ? -1 : 1;
sy = Random.Range(0, 2) == 0 ? -1 : 1;
GetComponent<Rigidbody>().velocity = new Vector3(Random.Range(5, 10) * sx, Random.Range(5, 10) * sy, 0);
//GetComponent<Rigidbody>().transform.Rotate(20,-5,0);
}
// Update is called once per frame
void Update () {
}
}
Comment
Your answer
Follow this Question
Related Questions
Issues with copying Y axisrotation of another object 2 Answers
Clamping X rotation on camera. 1 Answer
transform.rotate 4 Answers
Rigidbody rotation vs Transform rotation 4 Answers
Adding quaternions using a seperate axis 0 Answers