Comments and answers for "Unity 2D Rotate Problem!"
http://answers.unity.com/questions/509768/unity-2d-rotate-problem.html
The latest comments and answers for the question "Unity 2D Rotate Problem!"Comment by D3m0nE on D3m0nE's answer
http://answers.unity.com/comments/510252/view.html
okey,
forgot about the Box
can u give me code to flip the Weapon Horizontal?
i tried SetTextureScale , didnt work well for meThu, 08 Aug 2013 01:18:35 GMTD3m0nEComment by robertbu on robertbu's answer
http://answers.unity.com/comments/510107/view.html
When you tossed in the box, I was confused about how you constructed your game. I don't know the rotational relationship between the two, nor how you defined your pivot. Just guessing, I think all you need to do is flip the texture as the cursor crosses the boundary. The can flip the texture by changing the tiling/offset. [You can use Material.SetTextureScale()][1]. The default scale is (1,1). Change either value to -1 to filp. You can use the same code above that calculates the Dot product to select left and right.
[1]: http://docs.unity3d.com/Documentation/ScriptReference/Material.SetTextureScale.htmlWed, 07 Aug 2013 21:31:25 GMTrobertbuComment by D3m0nE on D3m0nE's answer
http://answers.unity.com/comments/510082/view.html
Umm, its seems i need another solutionWed, 07 Aug 2013 20:51:23 GMTD3m0nEComment by robertbu on robertbu's answer
http://answers.unity.com/comments/510020/view.html
As I mentioned in the answer, the values inside the Euler() were just placeholders. Play with other values until it works the way you want. With the gun pointed left, change the rotation in the inspector until you get what you want. Then use that value in the Euler() call in the code above. If something is going to work then it will be something like (180,0,0) or (0,0,180), or (90,180,0).
Note I suspect given the 2D and 3D nature of your problem, that this form of rotation might not give you what you want...that there will be no Euler() values that display the gun and the box correctly. This is especially true given that planes are one sided. That is why I suggested changing the texture rather than complex rotations to start with. If your problem can be solved by rotating, then some value in the Euler() call will work.Wed, 07 Aug 2013 19:34:51 GMTrobertbuComment by D3m0nE on D3m0nE's answer
http://answers.unity.com/comments/509997/view.html
Sorry, but i Didnt Get it ..
here is the CodE :
private var mousePos : Vector2;
private var screenPos : Vector3;
public var child : Transform;
function Update () {
mousePos = Input.mousePosition;
screenPos = Camera.main.ScreenToWorldPoint(Vector3(mousePos.x, mousePos.y, transform.position.z - Camera.main.transform.position.z));
transform.rotation.eulerAngles.z = Mathf.Atan2((screenPos.y - transform.position.y), (screenPos.x - transform.position.x))*Mathf.Rad2Deg;
var dir = screenPos - transform.position;
if (Vector3.Dot(dir, Vector3.right) > 0) {
child.localRotation = Quaternion.Euler(0,0,0);
}
else {
child.localRotation = Quaternion.Euler(0,180,0);
}
}
and this Script is attached to the Weapon Transform[Inside The Player] what is the child then?
anyway this is what happend when i added your code
![alt text][1]
[1]: /storage/temp/14026-cccccxxx.jpgWed, 07 Aug 2013 19:13:58 GMTD3m0nEAnswer by robertbu
http://answers.unity.com/answers/509896/view.html
The easy way to do this is to use a empty game object with the visible object as a child. You would then detect the left/right and do whatever flip you wanted to the child.
dir = screenPos - transform.position;
if (Vector3.Dot(dir, Vector3.right) > 0) {
child.localRotation = Quaternion.Euler(0,0,0);
}
else {
child.localRotation = Quaternion.Euler(0,180,0);
}
The rotations here are just placeholders. You will need to figure out what rotation you want in the inspector and then fill in the correct values. I would be more efficient to precalculate the rotations in Start() and then just assign the Quaternion in Update().
Start() {
qLeft = Quaternion.Euler(0,180,0);
qRight = Quaternion.Identity;
}Wed, 07 Aug 2013 17:39:46 GMTrobertbuComment by D3m0nE
http://answers.unity.com/comments/509790/view.html
not exactly
when cursor is on the right panel then moved to left panel
i want the whole character to rotate to the left panel not only the weapon
sorry for my bad EnglishWed, 07 Aug 2013 15:12:18 GMTD3m0nEComment by robertbu
http://answers.unity.com/comments/509786/view.html
I'm trying to figure out what you are asking here. My best guess is this:
![alt text][1]
That is when the cursor is place as on the left panel, the gun has this orientation, and when the cursor is as on the right panel, the gun is flipped.
If this is what you want, it might be easier to have two textures and flip the textures for each angle rather than write rotation code to do the filp. Plus you have the added complication in a flip that planes are one sided.
[1]: /storage/temp/14006-2dflipangle.pngWed, 07 Aug 2013 15:04:23 GMTrobertbu