Hi, I'm attempting to make a side scrolling gamemode, and I want to have a crosshair that can be moved around without moving the playermodel left and right, just up and down, and sometimes the other direction depending on the cursor's pov
Look into modifying your view angles in [URL="https://wiki.garrysmod.com/page/GM/StartCommand"]StartCommand[/URL] using [URL="https://wiki.garrysmod.com/page/CUserCmd/SetViewAngles"]CUserCMD:SetViewAngles[/URL]
Draw some pictures explaining what you want
[QUOTE=Donkie;50663073]Draw some pictures explaining what you want[/QUOTE]
Like this but the crosshair is moved by your mouse and the character always looks at it
[IMG]https://i.gyazo.com/611b0c438e5ccfc6602ef1cc86531756.png[/IMG]
[QUOTE=Moosicorn;50665533][url]http://wiki.garrysmod.com/page/gui/ScreenToVector[/url][/QUOTE]
Thank you, should I use draw/surface to draw the crosshair?
[QUOTE=TacosCANrap;50665760]Thank you, should I use draw/surface to draw the crosshair?[/QUOTE]
Either should work.
[QUOTE=VeXan;50665784]Either should work.[/QUOTE]
Okay, I'll try it out ,thanks
[QUOTE=blueangel512;50667273][/QUOTE]
You don't have to copy and paste from the link XD I can read
[QUOTE=Melted Bu11et;50663071]Look into modifying your view angles in [URL="https://wiki.garrysmod.com/page/GM/StartCommand"]StartCommand[/URL] using [URL="https://wiki.garrysmod.com/page/CUserCmd/SetViewAngles"]CUserCMD:SetViewAngles[/URL][/QUOTE]
How can I show the mouse but hide it? because otherwise it's position is at the middle of the screen
[QUOTE=TacosCANrap;50674794]How can I show the mouse but hide it? because otherwise it's position is at the middle of the screen[/QUOTE]
I'm confused now. I interpereted the picture as you wanting to be able to pitch up and down by aiming normally but not be able to yaw at all. Do you want to use the mouse to aim? If so, it's a bit more complicated. A way I can think of is using [URL="https://wiki.garrysmod.com/page/util/IntersectRayWithPlane"]util.IntersectRayWithPlane[/URL] and for the ray origin putting the position of the CalcView camera, and the direction putting in [URL="https://wiki.garrysmod.com/page/gui/ScreenToVector"]gui.ScreenToVector[/URL] using the mouse's position. Then, with the position you have, you subtract it from the players shoot position and turn that into an angle, then set the players view angle to that angle.
[QUOTE=Melted Bu11et;50676492]I'm confused now. I interpereted the picture as you wanting to be able to pitch up and down by aiming normally but not be able to yaw at all. Do you want to use the mouse to aim? If so, it's a bit more complicated. A way I can think of is using [URL="https://wiki.garrysmod.com/page/util/IntersectRayWithPlane"]util.IntersectRayWithPlane[/URL] and for the ray origin putting the position of the CalcView camera, and the direction putting in [URL="https://wiki.garrysmod.com/page/gui/ScreenToVector"]gui.ScreenToVector[/URL] using the mouse's position. Then, with the position you have, you subtract it from the players shoot position and turn that into an angle, then set the players view angle to that angle.[/QUOTE]
Thank you so much, this was really helpful, but there is still a problem(at least for me). If I get the position of the mouse, I have to have the mouse enabled, but I don't want to show the mouse
Sorry, you need to Log In to post a reply to this thread.