How can I make the cursor invisible, but still allow it to retain a x and y value? - python-3.x

So essentially what I want is the cursor to not have a image or shape to it. My code, which can be summed up as this, is a game where a player faces towards the mouse position (using atan(y/x)) I tried using pygame.mouse.set_visible(), and while it makes the mouse invisible, I notice that the mouse coordinates are static and didn't move, and so the direction the player was facing always stayed the same. How can I get a mouse cursor that is not seen/visible but still can have a changing x and y value based on movement of the mouse/touchpad? Thank you, and if you'd like to ask me anything more about this problem to get information, please feel free to ask me in the comments.

Well, I found this question answered by the asker of it.
It looks related to your question: check here
Simply, it is suggesting you to use this piece of code:
pygame.mouse.set_cursor((8,8),(0,0),(0,0,0,0,0,0,0,0),(0,0,0,0,0,0,0,0))

Related

Avatar removed from Pivot point

I was animating an avatar, and was trying various things out, and all of a sudden she was transformed from her pivot point. She also lost the T-pose. I couldn't figure out how to get her back to the original state, removing the animation didn't help. I am going to deleting that avatar and start over, but first I want to learn from this.
I am really looking for a few things here:
how could that happen? It looks like somehow the state at some point of the animation became the new "ground" state or something.
is there anyway I could inspect this state, edit it, or failing that, reset it?
is there something I should read somewhere to understand this better? I found nothing
Screen shot of displaced avatar:
The top level inspector in the heirarchy:
Here is one with the animator controller:
Update:
The key was the suggestion by Fiffe that you need to make sure your flow gets to your exit state. In my case I was neglecting to do that.
There's few things that might be causing this. You probably wanna play around with animation clip settings - you can find them by selecting animation clip.
You can read more about it here https://docs.unity3d.com/Manual/class-AnimationClip.html
You probably want to turn off Apply Root Motion in your Animator too.
If that doesn't help you should check if you don't have any empty states (without animations) in your animator controller.

unity 2D (look at) object disappears

I have a moving object that I want to look at the target it's moving towards, here is my code:
void Update ()
{
transform.LookAt( target.transform.position);
}
The problem is the object does look at the target while moving, but it disappears from the screen, but it's there at the same :/
Edit: Since the game is in 2D view, the object kinda turns sideways, so when I was talking about it disappearing but still there, what is really happening is that it turns and faces the object it's looking at. I hope that makes things more clearer.
Check the sorting layer order of your 2d object. If it has an order less than the order of any other object then it will disappear behind it.
You can check it in detail from this link.
https://unity3d.com/learn/tutorials/modules/beginner/2d/sorting-layers

Right way of handling mouse input

I was playing around with navmesh agent and im pretty happy about the results i get. But i am a liitle bit concerned about the code getting complicated.
I want to organize my code in a way that allows me to edit it later without trying to figure it out what i did there.
what i need is basically is this:
Handle mouse click on ground, enemies, objects, skill / spell targeting, gui
Handle mouse over objects, enemies, gui
my approach was:
in update function raycast mouse position
check if the mouse was clicked
if clicked check the target tag : enemy, ground, object (loot) and
call a related function
if not clicked check the target tag again for hover effects.
so what would be the best way to handle all of these listed above? any code examples in any language would be appreciated.
thanks for your time
its been a while that i asked this question. i ended up using state design pattern explained here.

camera.lookAt not called when THREE controls are being used

I am working on a program, that uses THREE.RollControls, when the user goes too far away from the center of the screen, they tend to get lost, so I am working on creating a function that reorients them, facing the center of the scene.
What I had intened to do was simply call the following:
camera.lookAt(scene.position)
However, this has no affect. From what I was reading on different stack overflow questions specifically this:
ThreeJS camera.lookAt() has no effect, is there something I'm doing wrong?
It seems like their solution was to do the camera position change using the controls, rather then changing the camera itself.
I do not believe there is any 'Target' in the Roll Controls, so I don't know how I can reset where the camera is looking at based on a THREE.Vector3() Is there a simple way to do this, or will I basically have to:
So far I have 'attempted' to do the follow:
- Calculate the difference of position of the camera with the position of the scene.
- Normalize this vector
- Subtract it from the direction forward of the camera
- use this vector in controls.forward.add(thisVector)
but this doesn't do at all what I want (probably because I have no idea what I'm doing)
Thank you in advance for your time!
Isaac
The same thing bugged me too about the RollControls but I took a different approach in solving the problem. Since the controls are in the example code (in r55) you can modify the controls, as they are not part of the core library. You can see my modifications at http://www.virtuality.gr/AGG/EaZD-WebGL/js/three.js/examples/js/controls/RollControls.js
I introduced a local variable called mouseLook because I could not use the this.mouseLook. I initialized it to false and I only make it true when there is a button press i.e. when navigating in the scene. That solved my problem.

jQuery Collision Plugin for game character / div

I'm aware there are a couple question similar but unfortunately they haven't quite been the answer to my problem... as far as I can tell.
Over the past couple nights whenever I've had some free time, I've been fiddling with creating a little type of game, which you can see a snippet/example here (WASD to move - Note: It's not cross browser compatible yet)
I'm using a plugin called jQuery Collision, it in theory does exactly what I would want it to do, but the examples given are done with draggable objects with the mouse and I'm having a few troubles adding it into my experiment.
I've tried adding this to my 'W' key in the attempt to say when the player collides with the obstacle, the obstacle should be removed.
if ($("#player").collision("#obstacle")) {
$("#obstacle").remove();
}
Currently the obstacle is being removed but some times unexpectedly, if you place the player underneath the obstacle and press W (up) the box is removed, even though the player and obstacle haven't collided yet.
I've also tried other ways that I've seen in demo's which I also couldn't get working:
var collided = $("#player").collision("#obstacle");
if (collided.length > 0) {
$("#obstacle").remove()
}
Could anyone shed some light on what I'm doing wrong?
NOTE
I'm aware there are plugins out there like gameQuery, so please don't recommend I just use that instead :)
Try the plugin made to handle dragging:
http://sourceforge.net/projects/jquidragcollide/
The original suffers from the fact that as you drag around, the current position of the div isn't updated yet until you let go. It was meant to be a static collision checker. If you look carefully at the examples:
http://eruciform.com/jquerycollision/
...you'll see that, as you drag, the "overlap" is one frame behind. In order to not make assumptions about what the intended use of the module is (i.e. dragging), I left it as using whatever coordinates jQuery thinks the div is at. And that's why I created the dragging addition plugin. It has a lot of other bells and whistles, too, like "collision avoidance" during dragging.

Resources