Third Person Top Down - Can I rotate the player with the cursor disabled?

DannyPanizo

New member
Hi there!

I have been trying to set up the Top Down to use it as a twin stick shooter. I have been facing a problem (now solved thanks to another recent thread) of making my character rotate facing the movement of the mouse. I used the code provided as a solution and now my character always faces the cursor.

Problem is, I don't want to see the cursor on screen. I mean, if it was just the cursor, I will just change it's appearance or make it not visible by code (actually I haven't tried that yet), but I intend to make it playable with mouse + keyboard and with a gamepad too. I haven't plugged Rewired or InControl because I haven't purchased them yet (I know it's recommended in the documentation to integrate one of the two if you intend to use gamepads in your game).

Question is, I would love to know if there is a way to make my character turn on itself with the mouse and with the gamepad without using the cursor. Or, if I have to use the cursor to make it work, if this is something I gotta have some of those two external gamepad input assets to do so, because frankly I am a bit lost on what parameter is making the character turn.

Thanks in advance for your time!
 
When the cursor is visible, a ray is cast from to get a world position towards which the character turns. With no cursor it doesn't turn. With the controller setup it uses whether the cursor is visible to determine if mouse is being used, so if cursor is disabled you will not get correct function with mouse (the cursor doesn't just disappear, it's lock mode changes iirc). The simplest is probably swapping out the cursor by code to make it work immediately with no code changes (with mouse). Both gamepad and mouse should work (and should be identical in mechanics in topdown after the next update).You have the problem of how to tell if a player switches input mid game. I do tend to use rewired, which has a simple method for checking the last input from mouse, keyboard or gamepad and you could use that to set a state to enable or disable the cursor on the fly to give correct results. I may be wrong, but I don't think this is so simple to do in the basic setup. So your challenge is to detect if the player switches input and turn the cursor off and on as required (I do this by setting a state which changes cursor visibility if the input type changes).
 
Thanks for your quick reply DankP3!

I was suspecting that the function was a raycasting to the cursor after I have been tweaking and playing with the system around for the past days.

I guess the thing I have to work on now is to control the mouse X and the mouse Y with the right joystick of the gamepad, but between your reply and what I have been able to see on forums, I suspect that's something I gotta do with Rewired.

I also realized about the problem you pointed out, but right now I'm prototyping the movement and getting used to the feel of it. I just bought opsive and I'm trying to understand how all the systems work first :D

I think I will buy Rewired and integrate it sooner than I expected ;)

Thanks again, you were really helpful!
 
I guess the thing I have to work on now is to control the mouse X and the mouse Y with the right joystick of the gamepad, but between your reply and what I have been able to see on forums, I suspect that's something I gotta do with Rewired.

At the moment "out of the box" the gamepad will just work with the character looking in the direction of the right stick. If you are planning to use the right stick as a cursor controller, this will obviosly be a lot more clunky (less responsive and less fun to play than a mouse?) and will involve modification of or creation of a new viewtype to get the correct look direction. You will not need rewired to do this, you will need to write a new LookDirection method in the ViewType.

Out of the box you should get strafing and non strafing movement from both and with a monitor for which input is being used (for this i use rewired) you should be able to easy swap at runtime, just using states to control Opsive variables, like is cursor variable, eg.: https://drive.google.com/file/d/1sY02ZBHyk2nMhFPweMRcVx0lHPjOhSTt/view?usp=sharing
 
Actually what I want to do with the gamepad is what you described as being "out of the box" (which I saw in the demo level before buying), but I haven't being able to make it work on a level of my own. Maybe it's because of the code fix that is coming next week? I mean there was a thread about not being able to make the character follow the cursor in Top Down. I inserted the code provided by Justin and now it works wonders with the cursor, but I can't still turn with the gamepad.

Maybe I gotta double check the code, because what you showed me in the video is exactly what I am aiming for.
 
Yeah, the update fix should sort that out (it will currently turn on the gamepad with current script, but only if aiming and this will be changed so that it turns when not set to look in move direction) [the demo setup is 'always aiming']. The fix from the other thread was to specifically fix the mouse not doing that for the OP of that thread and in the interim topdown has been adjusted to make gamepad and mouse the same and as expected by the terms used. I dont work for opsive, but believe the update is soon.
 
Top