Godot: Can you change how a node moves along a path? - godot

I am trying to make a game where you command a crew of people, and the movement system is that if you click on an area, the crew moves there. Is there any way to not have the node (the crew) follow the path I made in the order that I put down the points? Because the way they move right now is by following a Path2D.
I have put down Area2D nodes where when the crew overlaps them, they stop moving along the path. But I cannot figure out how to get the crew to move along the path not in the order that I placed down the points.

Related

Change mouse cursor when entering/exiting Area2d

I have tried every google result that seems relevant and cannot find a solution to something I'm sure is simpler than I'm making it. There's a possibility all of the results are outdated, as the official documents don't seem to offer what I'm seeing in search result suggestions.
When the mouse enters an Area2D, I want the mouse cursor to change to the hand pointing cursor. When I exit the Area2D, I want it to change back to the pointer. I am not looking to use custom cursors, just the basic ones already implemented in GODOT.
I know how to use mouse_entered/mouse_exited signals. I just can't determine the correct code and location to make the change happen.
When the mouse enters an Area2D, I want the mouse cursor to change to the hand pointing cursor. When I exit the Area2D, I want it to change back to the pointer. I am not looking to use custom cursors, just the basic ones already implemented in GODOT.
For that, the functions you want are Input.set_default_cursor_shape and Input.get_current_cursor_shape.
I know how to use mouse_entered/mouse_exited signals. I just can't determine the correct code and location to make the change happen.
You place the code in whatever signal handlers you connected. I remind you that you can connect the signals from the IDE in the "Node" panel, "Signals" tab. And in the code, you should see a green icon next to the func is connected to a signal. See also Signals.
For example, I connected them to a script in the same Area2D, and added this code:
func _on_Area2D_mouse_entered() -> void:
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
func _on_Area2D_mouse_exited() -> void:
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
Or if you want to store the previous CursorShape, you can do this:
var old_cursor_shape:int = Input.CURSOR_ARROW
func _on_Area2D_mouse_entered() -> void:
old_cursor_shape = Input.get_current_cursor_shape()
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
func _on_Area2D_mouse_exited() -> void:
Input.set_default_cursor_shape(old_cursor_shape)
See CursorShape for the values. Note: There seems to be a bug in the current beta that cause these to not autocomplete.
Reason why mouse_entered/mouse_exited might not work.
Assuming they are correctly connected.
If there is any Control (for example a Container or a background) overlapping a Node2D - such as an Area2D - regardless if it is in front or behind visually. It will prevent it from taking the input. Thus, you must set its mouse_filter of the Control to Ignore.
And make sure the collision_layer and collision_mask of the Area2D are not empty (0), input_pickable is true, and of course the Area2D has a valid CollisionShape2D or CollisionPolygon2D. Otherwise mouse_entered/mouse_exited won't work.
Also, I remind you to pay attention to any errors reported by the IDE.
One thing I recommend you can do would be to make an Area2D as a child of the root node (most likely a Node2D) rename the new Area2D to whatever you want (as long as it isn't named Area2D. For the sake of teaching you, I'm gonna rename it to CursorBox) and attach a script to that new Area2D. Add a CollisionShape2D node as a child of the Area2D, set the shape as a circle, and set the radius to 0.5. Next, go to the top right and press the node button. Connect "Area Entered' and "Area Exited" to the CursorBox. Inside of your script, make sure your functions look like what I have written below.
extends Area2D
var mouseCheck = false
func _on_CursorBox_area_entered(area):
if area.name == ("Area2D"): #This `Area2D` its looking for would be the buttons Area2D
mouseCheck = true
func _on_CursorBox_area_exited(area):
if area.name == ("Area2D"):
mouseCheck = false
The mouse check is just there to see if it works, obviously put your code in there, whatever you need to put in. I would imagine you have some animation you want to play or something. If you have any more questions, just reply and we'll see what else we can do to fix it.

HoloLens user position

Is there a way to get the position of the HoloLens user? I want to send the position of user back to PC and then update my hologram accordingly.
Is there a way to do so? I haven't been able to find any API using which I can send back user's location to my computer.
We can use the initial position and orientation of user as origin and then calculate everything relative to it.
Camera.main.transform is the position of the head.
The best way to do this would be to use the HoloToolkit-Unity. You end up adding a prefab called "HoloLensCamera" to every HoloLens project. The starting position and rotation for the root GameObject of HoloLensCamera are always 0,0,0. As you move around, the values of position and rotation are updated relative to your movement.
The HoloLens create start position, it's 0,0,0.
He can't give you a longitude/latitude value because he don't have a compass !
I recommend you to check sharingwithUNET in holotoolkit-unity or now Mixedrealitytoolkit-Unity. If you run app in the unity and also run the same app in the hololens you can see the location of the both app users. One you can control in unity and another is the location of the hololens user. When you move with your hololens you can see it updates the location in the app on computer in unity. I'm not sure if this is exactly what you need but I'm sure it will help you out if you check how it works.
Good luck!
Hololens hasn't any API for getting altitude and longitude. All camera positions would be relative to initial.
You should choose the another way. Find any noticeable item at any wall (or floor, or sail). Attach Spatial Anchor to the item. And calculate positions to the anchor. Then share the anchor to all Hololenses in the room.

Add Lines To Google Earth Using KML

So, basically, I'm trying to figure out a way that I can draw lines (say, representing the flight path of an RC plane or something) onto Google Earth using KML. Here's the kicker though: I want to give it an initial location, and then check somewhere to see where to continue drawing the line to, draw the line, and leave it be. Once it's done, I could then move it around.
Ex:
Starts at a point A in google Earth
Checks File XYZ.kml on //someserver
XYZ.kml has updated coordinates to draw to
Google Earth pulls in those coordinates and extends the line
Repeat 2->4 until complete
View completed flight path from 3rd person.
Does anyone have any ideas on how to do this? It seems like it can change the location of a model or something in this fashion, but you would have to watch it first person. I haven't been able to figure out how to get this particular functionality to come out right.
You have a few ways of doing this, here is just 2.
Create a LineString via a networkLink and then use the Update feature to update your LineString (ie replace with new version)
Create a LineString and then use .getCoordinates().pushLatLngAlt() to build upon it.
Edit: Sorry, as pointed out in comments, Option 2 is for GE Plug-in, not standalone version
See this SO question for some help on using option #1
See this SO question for more info on option #2

Z-order while drag and drop between different scene graph branches

I have an interface where i want to drag an element from a list of elements to a GridPane. The grid and the list are in different branches of the scene graph. Because of that, my draggable Node disapears behind the GridPane, when i want to drag it over the grid.
One possible solution would be to add the draggable node to a frontmost Pane, where it will be in front of all other nodes. Unfortunately this means i have to remove the node from its old position before i know that the drag and drop gesture will be successfull, which leads to all kinds of additional code.
Is there a way to have a node rendered in front of all other nodes without changing its position in the scene graph?
Is the "draggable Node" actually being moved around by the cursor? If so, you could create an Image from the node and drag that around?

On Visual C++, How to make a simple paint program?

I want to make a simple paint program on visual c++ which allows the user to draw a path of a series of straight lines which follow on from each other. Once the user is done this, they should double click to stop drawing. It is important that I record the co-ordinates of the beginning and end points of each line of the path because I want to use this information to find the magnitude and direction of each line using simple math. Please can someone give me somewhere to start and any other guidance.
You should start with a tutorial in: MFC.
Learn the basics: Document/View architecture and
how painting is done (GDI and device contexts).
Basically, you should:
1. create an MFC application (SDI - single document interface),
2. Handle the OnLButtonDown (WM_LBUTTONDOWN), OnMouseMove (WM_MOVE), OnLButtonUp (WM_LBUTTONUP).
3. Maintain an dynamic array/List (TypedPtrList) of the points
4. handle the double-click event for detecting completion.
You should use the Invalidate() function on (after) each click, in order to see the changes
on the screen.
That's just a little bit of information to get you started
You'll want:
a class or struct to represent a point (if you make it a class, it could have computation methods that would, for example, calculate the distance and direction to another point)
a member variable: an instance of a container class (list, array, etc) to hold your points
a member variable: a boolean flag to represent whether you are drawing or not (starting with not)
and you'll need to handle:
the mouse click event to instantiate a point and add it to your container
the mouse move event to draw a line from the last point to the current mouse position if the drawing flag is true
the mouse double-click event to add the double-click location to your container of points and turn off the drawing flag
Yaron's strategy doesn't draw lines until 2 points are clicked. Mine uses "rubberbanding" to anchor the first end of the line then let the second end follow your cursor until you click to anchor it down. Use whichever one you like better.
if i were you i would use Qt.
Qt widgets are great for user interface. you should check qt examples...
if you want to make an image processing behind, you can use imagemagick library.
this library is great for any image manipulation.

Resources