Hi, i'm trying to make a 2D platformer game, with some mini games to pass through from time to time. in one of them there is a circle (in black) rotating with the following script:
void Update ()
transform.Rotate (0, 0, 90 * Time.deltaTime);
And there is a child Cercle (in red) attached to it , that starts moving when it's not anymore child of the black circle (i used a bool called : joined) here is the script for movement:
public float speed =15f;
if (joined == false) //not anymore child of black circle
Vector3 pos = transform.position;
Vector3 velocity = new Vector3 (0f, speed * Time.deltaTime, 0f);
pos += transform.rotation * velocity;
transform.position = pos;
What i want to have is that when i click on mouse button and the red circle is released, i want it's rotation to be set in the right way for it to move as illustrated in the picture, whatever the rotation it has when it was joined with the black cercle.
here is how the red circle get joined with black circles:
void OnTriggerEnter2D (Collider2D col)
if (col.tag == "BlackCircle")
sorry if i couldn't make it so clear for you (i'm noob) don't hestitate to ask me for more clarification. thanks!
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
121 People are following this question.
Walking around a sprite
How can I make my player's gun point at the cursor, not the player itself?
[Solved] Problem with achieving rotation relative to current acceleration value
Simple player rotation help
Create Field of vision