|
Hi all, I am want to make a gameObject (a cube) rotate around its x,y,z axis while i press and drag the left Thank you in advance! Update 15/01/09 I found this c# camera component http://www.unifycommunity.com/wiki/index.php?title=MouseOrbitZoom which does exactly what i want with the difference tha I want to do it OnMouseDrag and not move the camera but the GO.
(comments are locked)
|
|
Thank you all for your answers. I've taken a different approach and I used Quaternions. Here is my code which drag rotates an object with easing.
My only problem is that if you move the mouse very fast it bounces the object over the axis you moved it. It can be solved with using ray casting but then it will constrict the drag over the object which i don't want... Any ideas how to prevent this bouncing? Thanks.. I am looking for it too... :)
Mar 09 '11 at 07:32 AM
Thet Naing Swe
Thanks, I was also looking for something like this ^^
Jun 25 '11 at 06:56 AM
Aer93
can't you scale up the collision box on the object to fill the screen? this way you are always touching the object and you can use ray cast.
Feb 01 '12 at 11:55 AM
vengeance92
(comments are locked)
|
|
Some quick javascript:
(comments are locked)
|
|
Hello,
Also, make sure to tag your question as answered if you found a solution. All the best, -Lincoln Green
(comments are locked)
|
|
This is also another and not so good approach pragma strictvar hit:RaycastHit; var obje:Transform; function Update () { var mPos=Input.mousePosition; var p : Vector3 = camera.ScreenToWorldPoint (Vector3 (mPos.x,mPos.y,1)); var a : Vector3 = camera.ScreenToWorldPoint (Vector3 (Screen.width/2, Screen.height/2, 1)); if(Input.GetButton("Fire1")) { print("fire 1 basildi"); var ray = Camera.main.ScreenPointToRay (Input.mousePosition); if (Physics.Raycast (ray,hit, 200)) { print("ray attik ve carpti"); if(hit.transform.gameObject.tag=="Player") { //hit.transform.position=a; if(Input.mousePosition.x>Screen.width/2){ hit.transform.Rotate(transform.right, -Time.deltaTime*50); } if(Input.mousePosition.xScreen.height/2){ hit.transform.Rotate(transform.up, -Time.deltaTime*50); } }
(comments are locked)
|
|
It's not clear what you exactly want but the following script rotates cube around x axis when pressing left or right arrow (or use joystick or whatever is set up for left-right movement). I guess Brian did better understand what you want. I see now that you probably meant 'left mouse button' instead of 'left arrow'.
Jan 15 '10 at 12:54 AM
Jaap Kreijkamp
Sorry I meant mouse yes...
Jan 15 '10 at 09:20 PM
chchrist
(comments are locked)
|
1 2 next page »
