Need help on using MouseDelta

Hi, I’m programming a game(3rd person) where the rotation of the character in y-axis depends on the mouse delta in x-axis. At the moment, i’ve programmed so that it will take the delta value of the previous mouseX position with the current mouseX position. The problem is then that , when the mouse is getting to the end of the screen , i can’t turn more,
I think that HandleUtility.niceMouseDelta should solve it, but i don’t know how to use an editor class :S . If you know an anwser I’d be happy if you shared it with me.

maybe try cursor lock? works like this Screen.lockCursor = false; use a script similar to this

function Update() {
     if (Input.GetKeyDown("escape")) {
		if (pause == false) {
			pause = true;
		}
		else if (pause == true) {
			pause = false;
		}
	}
        
        if (pause == false) {
		SendMessage("Unpause");
	}
	
	else if (pause == true) {
		SendMessage("Pause");
	}
}

function Pause () {
	Time.timeScale = 0;
	Screen.lockCursor = false;
}

function Unpause () {
	Time.timeScale = 1;
	Screen.lockCursor = true;
}

The lock cursor am I sure I will use in my script, but the thing is that I need to somehow locate the deltaposition of mouseposition in the x-axis and that code doesn’t do that. But thank you for replying. If you have more suggestions, feel free to tell me.

I’m sorry, but im having a hard time understanding exactly what you need. if you could try to explain a little more, like how it works, what ist supposed to do, that’d be nice

If you lock the cursor, your current mouse delta code will no longer stop when the mouse hits the edges of the screen - since it can’t (it’s locked to screen center).

But because the mouse is locked it wont move (and my current code is dependent of the mouse movement).

I’ll try explain my current code a bit more:
It takes the mouseposition from the last frame and the mouseposition from this frame and uses the delta of those two positions to rotate the character.

Problem:
If the mousecursor gets to the edge the delta will be 0 since the mouseposition from last frame is the same as the mouseposition from this frame.(x-x=0). The same thing will happen if I have it locked in the center.

What I’m thinking of, is if there’s a way of directly getting the mouse delta without using the mouse-cursor position. If there is , then I would be able to have the mouse cursor locked in the center.

why dont you just use the MouseLook script?

Oh, that was a great idea, I hadn’t thought of that. Thank you very much.

your welcome

Locking the cursor still gives you the movement in Input.mousePosition, it just resets it after you’ve had a chance to play with it.

True, I thuoght about that before. When i tried it in all haste, I got the bug that every time i tried to rotate the character, it got reseted to the start rotation, because of that the mouse always got to the center again. But I guess that I could do some tweeks in the system so that it should work just fine.
I’ll try both suggestions and see what fits best in my script. Thank you for bringing up the idea.