4 hours ago, davejones said:
it should recognise ONLY the tip of the sword and flash green
OK, my apologies; didn't know you where a complete beginner so I wasn't making things clear. Sorry.
Rememer Unreal's UI, wasn't designed to collide with each other. To do this will involve checking the collisions yourself, or building a blueprint that adds collisions to the UI. It would be better to use Unreals 2D part for this.
The easiest way to do this would be to combine both the UI widgets and 2D engine. That way when the player clicks on the sword, it disappears but a 2D sword is spawned where the player is touching.
The spawned 2D sword would use the widget size, that way it gets the benefit of Unreals scaling for mobile.
4 hours ago, davejones said:
I have a 2D widget of a sword. As I drag the sword if the sword tip lands on an image it should recognise ONLY the tip of the sword and flash green.
You need to give Unreal some way of knowing what part is the tip of the sword. I would use 2 collision boxes, one for the handle and one for the blade. Again this would only work with Unreal's 2D engine.
You could also use 2 widgets for this, or two images in a widget; whatever you want. The important part is that Unreal must have some way to know the blade from the handle.
4 hours ago, davejones said:
1) I want to be able to drag and drop the sword.
2) I want to be able to drag the sword from the top of the sword.
I assume you haven't learned vector math yet. You really need to learn about vectors and how to work with them, they are used for almost everything.
Example:
The Sword_Widget has some vector 2 position, this is based on its origin. When you click/touch you can find your vector 2 position.
Sword_Widget position- Your_position = offset. Let's say you touched at (0,-12) and the sword is at (0,-10) = Sword(0,-10) - Your(0,-12) = Offset(0,2).
Because the offset is (0,2) we know that to drag the sword from the same place we always need to add the offset (0,2) to the touch position. The image explains better:
4 hours ago, davejones said:
3) The On drop function is only called when the tip of the sword is on the image
Like I mentioned before, you need some way for the engine to know what the top is.
Normally UI collision detection is not this advanced. But if you use one sprite for the blade and a other sprite for the handle, you could check distance to blade: http://www.mathwarehouse.com/algebra/distance_formula/index.php.