I have my prefabs for my characters but I'm lost wondering how am I able to do a drop-able unit like Clash Of Clans. I'm almost done with the game i'm making does anyone have an idea or suggestion to do it? source code or tutorial will be highly appreciated!
just like items in an inventory
instantiate your prefab on touch.
you can either iterate through a loop and keep instantiating until your out of troops,
or
you can use a bool and an update method, to spawn one unit at your touch/mouse down,
move its position to mouse/touch position in update, as long as still touching,
finally in your mouse/touch up you stop updating his position manual and release him.
if you would like some help with the code for either implementation let me know!
Related
I am a beginner with unreal engine. My end goal is to play an animation in the user interface that makes the word "coin" move. I have a blueprint called "BP_Coin" which spawns coins that the player can pick up and have it added to their total. When the coin is picked up, I can't get the animation of the "coin" text to play. The animation is in the widget blueprint called UIWidget.
I assume casting is my only issue, but am I doing this inefficiently? What's the easiest way to accomplish something like this?
I've followed a tutorial that mentions creating a reference with a game instance class and using that in the object slot of the CastTo, but I was unsuccessful. It would always come up with "cast failed".
There should be a CreateWidget node (documentation) somewhere in your blueprints in order to even display widget on player's screen. You may pass output of that node into CastToUIWidget function to achive what you probably need.
Hope that answers you question.
So i'm working on this project and i'm using it to finally learn how to animate in 3D (taking a small break from coding hehe)
So here i am faced with a problem and i have no idea what i did wrong. First let me explain how everything works.
So the Animator is attached to the player, and the player obviously has a structure of legs arms...etc
everything inside the player is being animated by this animator.
So i have a weapon (a wooden sword) that has it's pivot attached to it's bottom (in case it helps to know)
i'm animating it from that pivot point, which happens to be the parent to which the sword model is a child to.
When i hit the V key the weapon gets instantiated in the player's hand (which is an empty gameobject) and when i press the F key the player attack and activates a trigger in the animation that starts the attack animation.
But the animation is not working properly. more precisely the key frames of the weapon are not being player(as you can see in the video all the rotation axes give the coordinates of 0 0 0 throughout all the animation.
But, ...and this is where the strange things start!... when i manually go through each second to play the animation and see what's happening, you can see that those coordinates start to change and it shows the animation exactly as it's supposed to be. then when i switch back to idle state so that i can start moving around the player normally. when i hit the F key to attack the correct animation is player and no problem happens... Magic? i don't think so... :p
what do you think? what could be causing this problem.
Who's up to solve my riddle :cool:
Seriously guys what's going on here, i need help.o_O
Thank you all ;)
The Video : HERE
In general: You are using an ALPHA version 2019.3.0a4 ... in short don't.
As any alpha version it is like to have some bugs .. especially since you are not even using the latest instance of the alpha which afaik would be 2019.3.0a12!
2019.3.0b1 is actually even already in BETA state a lot of former bugs should be fixed there - but it is still a beta release meaning it is not ready for production.
So in general don't even use the beta. Rather stick to the latest stable release version which would now be 2019.2.3f1
There is not directly listed one relating to the animator not finding a certain object at first and then not animating it .. but as said alpha version are likely to have bugs. Also since it is an instantiated prefab the original instance will be gone .. then by name it gets re-assigned by the animator so the main issue might be that you instantiate it in the first place instead of just having it already from the beginning.
You should consider only using the parent/pivot object of that sword and not animate the sword itself at all. Simply spawn it as a child of the animated pivot and you should be fine,
I'm trying to implement drag and drop using unity's EventSystem. When I start drag one object using IDragHandler - IPointerEnterHandler on another object doesn't works from time to time. Does someone know how to solve this? Or maybe someone know the reason why this restriction existing?
Since EventSystem works with raycasting, there may be another object which blocks the ray. So, you should make sure there is no other object that may block raycasts.
If you are using dragging for UI elements you can change other objects CanvasGroup to canvasGroup.blocksRaycast = false or you can set it as lastSibling https://docs.unity3d.com/ScriptReference/Transform.SetAsLastSibling.html.
If you are doing it with gameObjects you can change your object's layer to something higher from others. Such as 10. But do not forget to make it default again when you are done with it.
If you can share a gif or something else, it would be easier to help you.
I created a bunch of non-AI animations for enemies that do basic back.forth or up/down motions. Everything was working perfect until I started working on the Boss of the level. The boss has his own tag "Boss" and enemies have their own tag as well. Anyway, the problem is when I click start, every enemy leaves the game board. I can see them animated above the game board still doing their routines.
Any clue as to why this happened and how to fix it? I'd really, really hate to have to scrap all the enemies and start from scratch...
I used the Animation tool inside unity.
Extra Note: I created an EMPTY and moved all of my enemies into that Empty object to clean the hierarchy panel up. The animations were fine before this.
************** Currently Resolved **************
Whew! Okay, so apparently Unity doesn't like it when you move your animated stuff into an empty AFTER being animated. I FIXED them by simply removing them from the EMPTY that I had placed them in. However, I'd still like to know why this is. So any useful resources, links, manuals, personal insight/observations or anywhere I can read up on this would be appreciated!
Here is an explanation what happened:
The moment you dragged them all into the empty GameObject I guess this object probably wasn't placed on 0,0,0 in the Scene.
So Unity automatically changed all the local position values of your enemy items to fit the current position offset to the empty object.
Result: In the editmode they don't change their actual global position in the scene but their local position. This is supposed to happen if you just want to organize stuff.
However, now when you start the game and the animations are played, the animators change all the local positions to whatever is stored in your animations.
Result: all objects jump back to their original localPosition which had an offset to the empty GameObject.
To solve this make sure the empty GameObject is at position 0,0,0 and optimally has rotation 0,0,0 and scale 1,1,1 before you drag anything into it.
Easiest way to achieve that is by clicking reset in the empty objects Transform component before starting to drag stuff into it.
i am working on a Unity project where i want to show a car coming out from a garage and travel around the house.
so i created Animation Clips of the door opens, car driving around the house and some others.
lets call them animations a, b, c.
now i want to make this animation run in sequence,in this order a -> b -> c.
how can i managed this?
a method without writing scripts is preffered.
good reference will also be great! im kind a new to unity, know key framing aninations. wanted to beleive that there is an easy way to make it trough.
thanks!
You could add an animation event at the end of your animations playing the next animation. This would require a script, but a very simple one. Add the name of the animation in the event, so it's reusable.
I think without scripting you can't solve you problem so you can look this link or ask someone write your code
http://docs.unity3d.com/ScriptReference/Animation.html
https://unity3d.com/ru/learn/tutorials/modules/beginner/animation