I have a custom mouse cursor that I have tried updating in OnGUI, Update, and LateUpdate (not all at the same time). I am getting a result that I have seen in some games where I disliked the controls, which is that the mouse cursor appears to be reacting or moving slowly.
Whats actually happening is that it seems that the system mouse updates much more often than the custom mouse cursor. This is apparent when I can visually notice (for a split second) than my system mouse is in a different position than my custom cursor if I move the mouse fast.
However, I’ve seen games with very responsive custom cursors and I’m wondering how I can get that same effect. What can I do to make my custom mouse update at the exact same speed as the system mouse?
We already apply custom cursor in our project and its work fire for me. Here is the code.
var customCursor;
function Awake(){
customCursor=GameObject.Find("customCursor").GetComponent(GUITexture);
Screen.showCursor=false;
}
function Update(){
customCursor.pixelInset.x=Input.mousePosition.x-customCursor.pixelInset.width/2.2;
customCursor.pixelInset.y=Input.mousePosition.y-customCursor.pixelInset.height;
}
Have you tried commenting out the code that hides the system cursor, then watching both at the same time? Try dragging your mouse around the screen slowly at first, then slowly getting faster. You will quickly see a HUGE delay between your mouse position and the custom cursor.
I was thinking that making the mouse move faster in unity could remedy this, but I’m not sure how it could since it seems to be an updating issue?
Yes, i tried it that time and its not smoothly follows to windows default cursor. Little beat lag over there.
Use the hardware cursor in Unity 4.
–Eric
Thanks for the tip Eric.
For anyone finding this thread, this is what Eric is talking about:
http://blogs.unity3d.com/2012/10/22/cursor-api/
This is actually EXACTLY what I needed, and what everyone else should be using. Make sure to note the 32x32 size requirement for windows.
Software cursors like I was using and what UnityCoder suggested are not very responsive and should be avoided.
Hi guys sooooo I was just fumbling around with my own custom cursor and I figured I’d share this thing on making it animated
I dunno, someone might be able to code it neater or something I haven’t been coding that long, only like 2-3 years and before that… man I was not VG designer material, thankfully now I am though
haha anyways!!
public Texture2D[] mouseCursorImages;
public int frameIndex;
public int maxFrames;
public float mouseAnimDelay;
public float frameRate;
****Inside Update
////If the player is in the menus or whenever you wish to have your animated cursor (or even Application.isPlaying)??
if(currentPlayer.onMenus)
{
mouseAnimDelay += Time.deltaTime;//Increase delay timer
if(mouseAnimDelay > frameRate) //If frameRate ticker reached, flip image and reset delay, if max frame is passed, reset to first frame
{
frameIndex++;
if(frameIndex >= maxFrames)
frameIndex = 0;
Cursor.SetCursor(mouseCursorImages[frameIndex], new Vector2(0,0), CursorMode.Auto);
mouseAnimDelay = 0;
}
}
Try disabling vertical synchronization to update the frames faster:
QualitySettings.vSyncCount = 0;