- Home /
card rotation :: Empty with two planes
hi folks!
just playing around with nice unity to get in touch and better knowing each other...
i want to create a dounble sides textured card and want to rotate it by click and tried the following - please tell me from which point on it could be done better - still here to learn from you!
I took one Empty and two Planes as Children of the Empty. Then I added texture and turned one of the planes to face down.
I added a script with a OnMouseDown-Function in it to at least print me into the debug log.
problem: nothing happens, when i click onto the card.
is this because its an empty?how could I do better?
thanx!
edit: here is the code. just starting to play around...
var rotateSpeed = 250.0; var rotating = false;
function Start(){}
function Update () { if(rotating){ rotateCard(); }
}
function OnMouseEnter() { Debug.Log(gameObject.name + " OnMouseOver"); renderer.material.color = Color.red; }
function OnMouseUp () { rotating = true; }
function rotateCard() { var theRotation = rotateSpeed * Time.deltaTime; //if(theRotation <= 0.5){ print(theRotation); transform.Rotate(0.0, 0.0, theRotation); //} }
It would help us answer if we could see your script. Care to oblige?
Answer by spinaljack · Apr 22, 2010 at 02:18 PM
Depending on how you implemented the mouse function you may need a collider on the cards but as elbon suggests you should edit some code into your question.
right. added the code. seems to need to add a colider, hm?
but how do i now rotate the plane children and not just the box collider?
the code should be in the parent object then when you rotate the transform all the children will rotate with it, unless it's a billboard or something...
Your answer
![](https://koobas.hobune.stream/wayback/20220612182805im_/https://answers.unity.com/themes/thub/images/avi.jpg)