Possible to create recoil with mouse pointer?
I was trying to no avail to create a recoil effect of the mouse pointer when you shoot your gun.
I have a crosshair that is at the X and Y positions of the mouse.
I tried to do a condition when i press button the gun fires and set -10 to crosshairs position for example. But that did not work.
Then i tought that maybe its because the crosshair is set to ALLWAYS be at X and Y of the mouse. So i made a counter instead set at 0 and made a condition that when the counter is at 0 the crosshair should be at mouse X and Y and so on.. but i did not get that to work ether.
Is there any way to do this?
Re: Possible to create recoil with mouse pointer?
Two ways:
1: Use the mouse object to actually move the mouse
2: Always set your crosshair's Y to being "MouseY - Global Value Recoil", then fiddle with "Global Value Recoil". Make sure you return it to 0 after a little while though.
Re: Possible to create recoil with mouse pointer?
Thanks but is there any more information on this?
Re: Possible to create recoil with mouse pointer?
Ah i think i got it to work with a recoil value thanks! :)
Re: Possible to create recoil with mouse pointer?
O no it did not work so well actually because when it has moved far enough at some side it wont go further in that direction.. I guess thats you thought i should return the value to 0 sometimes, but that does not work so well because then the crosshair will jump to some unexpected place all of a sudden?
Re: Possible to create recoil with mouse pointer?
When the player fires, you'd set the crosshair's Y to "MouseY - Global Value Recoil" which would instantly pop the crosshair like a recoil, and then you could just have another condition that checks if the recoil value is greater than zero, and if it is, subtract until it's zero. That would give the effect of the crosshair popping up when firing and then settling back down to the center of the mouse again.
How much you subtract from the value each loop would determine how fast the crosshair settles back to mouse center.
Re: Possible to create recoil with mouse pointer?
Quote:
Originally Posted by Konidias
When the player fires, you'd set the crosshair's Y to "MouseY - Global Value Recoil" which would instantly pop the crosshair like a recoil, and then you could just have another condition that checks if the recoil value is greater than zero, and if it is, subtract until it's zero. That would give the effect of the crosshair popping up when firing and then settling back down to the center of the mouse again.
How much you subtract from the value each loop would determine how fast the crosshair settles back to mouse center.
Would it not feel strange when you controll the crosshair after a shoot if it constantly tries to "pull" you in anohter direction?
Re: Possible to create recoil with mouse pointer?
What do you mean "pull" you in another direction? The crosshair should be the only thing moving during the recoil.
Re: Possible to create recoil with mouse pointer?
Quote:
Originally Posted by Konidias
What do you mean "pull" you in another direction? The crosshair should be the only thing moving during the recoil.
Yes but you said i should have a condition also to return the value to 0 after i have fired. That makes the crosshar slide or pull. It dont stand still after i have fired instead it moves toward the mouse
Re: Possible to create recoil with mouse pointer?
Isn't that what a recoil does? One way or another, the mouse cursor is going to be forced away from where you pointed it and then return to the mouse's position. You control how fast that happens, so that it doesn't affect gameplay too much. You might also try disabling player input so they can't move the mouse cursor during the recoil. Then the positioning code won't be dealing with you moving the cursor around during the recoil. (and before you ask, that is for YOU to figure out and design for your game) ;)