- Home /
Question by
robert_mathew · Nov 22, 2011 at 05:52 PM ·
rayhit
ray hit probelm
var mouseOverColor = Color.blue;
private var originalColor : Color;
function Start (){
originalColor = renderer.sharedMaterial.color;
}
function OnMouseExit (){
renderer.material.color = originalColor;
}
function OnMouseDown () {
var screenSpace = Camera.main.WorldToScreenPoint(transform.position);
var offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
while (Input.GetMouseButton(0))
{
var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);
var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;
transform.position = curPosition;
yield;
}
}
I am trying use this script for draging a five game object(mesh) in the screen it is working fine for me but at the center of the screen when i try to drag the object from the centre of the screen to other part mouse is not going over the object both mouse over function and draging of the object is not working mouse over and draging is working fine other than centre of the screen.I have kept this camera as main camera and disabled all camera in the game when using this camera .What is the reason benind mouse over and darging is not working .There is no obstacle in between camera and this game object.
Comment