Tag Info

Hot answers tagged

8

Well, I'm honestly not an expert on this but... I think it depends on how complex and varied you think the attacks will become. Since it's an RTS I'm guessing you'll have maybe 10-50 or so different units or structures with their own attack types. Option 1: If there is a relatively low number of units that will have attacks that are somewhat similar I ...


4

We just have to declare Awake, Update, and any other function created by us, to be public and virtual on the parent. Override the function on the children. public class AgentBehaviour : MonoBehaviour { public virtual void Awake() { // your code here } public virtual Vector3 GetVector3 () { return new Vector3(); } } ...


4

Generally, you want to avoid excessive hierarchy. What if a player wants to attack an object (such as a trap, or door?) How would a trap attack a player? What about environmental hazards? I would suggest an entity-component system over inheritance here. Give everything that has health a Health component, and give everything that can attack a Weapon ...


4

I don't know a whole lot about Unity and I haven't done game development in a while, so let me give you general programming answer to this question. I have based my answer on the knowledge I have about entity-component systems in general , where an entity is a number that is associated with N many components, a component only contains data, and a system ...


3

You seem to have rectangles that are sandwiched: You have rectangles A, B and C A directly above and is overlapping B, which is above and overlapping C. The update for A is done, pushes it a bit up. The update for B is done, pushes it a bit up because of C, and a bit down because of A. B hasStopped because it did not move because your [x|y]Shift is ...


2

When a unit/structure/weapon attacks, I would probably create an Attack (subclassed with all your fun details) that takes the attacker and the defender (or defenders). The Attack can then interact with the target/defender (slow, poison, damage, change state), draw itself (beam, ray, bullet), and dispose of itself when it's done. I can foresee some issues ...


2

I found out that the Content.mcgb is actually a little GUI helper and you can generate and easily load a .spritefont file with it. Steps: 1.Load the GUI app by double clicking the "Content.mcgb" file in the "Content" folder 2.Go to Edit -> New Item... -> Choose SpriteFont and give it a name -> Hit "Ok" 3.Go to Build -> Build (or hit F6) - You should get ...


2

One simple way of doing it could be to make a few alternate versions of the script and have different AI profiles for the enemies (just give them a random one when created). This way you could have one type that goes straight ahead like you have now, but also others that try to get the player by curving right or left. Maybe even one that makes some random ...


2

As this rapid google search states: gameObject.tag="new_tag"; Obviously your "new_tag" has to exist inside the editor.


2

Draw each circle on some memory, then after all are drawn, set the inside of every circle to zeros, clearing any intersection lines. clarification On some memory is meant to indicate separate texture Set to 0 is meant to indicate set to transparent. setting inside transparent on second draw sequence is fill with transparent color with fillcircle of radius ...


2

That sounds really odd to me. This might sound like a good idea if you've got some bad/biased RNG. Another possible use case would be some game with random loot where you'd like to guarantee your player to get some special drop once every x tries rather than having a very bad streak. However, for your own use case this doesn't sound very useful at all, ...


2

you might try having the on enter adding the enemy to a 'target list', and on exit/killing enemy have that entry removed from the list. using System.Collections.Generic; // lets use use the magical 'List' array List<GameObject> targetedEnemies; // List arrays let us add and remove stuff later, // that is, they do not have a maximum capacity and won't ...


2

As pctroll said, the right solution for you is to use virtual functions. To answer the question "how does Unity do that" without virtuals (i.e.: you don't have to override Awake or Update in MonoBehavior derived classes) they use Reflection to call theese functions by their names (string).


1

That seems like a very basic task, if I understood correctly. Obviously, if one node can fit only one blinky, then your function has to satisfy the following condition: Amount of blinkies <= amount of nodes. And there're several ways to loop until you have placed a blinky. One would be just decrementing the iterating variable: if(randomNode.walkable) { ...


1

Perhaps this is what you are looking for: transform.forward = transform.up;


1

Looks like the options are ... Implement your own version of the rigidbody script. Make your world a whole lot bigger and rotate it under the player as they move rather than rotating the player round the world.


1

I can see why you would want to do that, if the random number was a key seed to a sequence, having the same number twice would create the same sequence. You could create a table to use as your randoms at program start time, then check it for duplicates, and replace with another random till every number is unique. If you add all the numbers to a map while ...


1

If you don't care about the interior being painted in, there's a really simple solution. First, draw all circles in black. Next, draw all the circles again in white, with a smaller radius - basically subtract a border width from the radius. The result will be a constant thickness black border around a white area. You could maybe even use this black / white ...


1

You probably could draw, and save 'intersection points' any point where two circles draw a point at same location. Then use that set, knowing that inside and outside changes when an intersection occurs. You would then only need to check any one point between two intersections to know the status of an entire arc between any two intersections. Fewer checks ...


1

The GameObject car is not set to anything. That means it's null. This is exactly what the error message is telling you. Just because you happen to have a prefab named 'car' in your Assets folder doesn't mean you can name a variable car and expect Unity to know you're talking about the same thing. See my answer to your other question to learn one way to ...


1

If you put the prefab into a directory called Resources inside your Assets directory, you'll be able to use the Resources class and its load functionality. This will load a prefab up as a GameObject, which can then be instantiated. For example: GameObject myRoadInstance = Instantiate(Resources.Load("road")) as GameObject; Will create a instance of your ...


1

maybe you don't get the reference to the right animator, to TEST (or DEBUG) define it public public Animator anim; , run the game and watch in the inspector if it has referenced the right one. If the animator you need is attached to the same object where you attached the script it should work, but if they are not attached to the same game object it doesn't. ...


1

Simply draw your sprite before the call to GraphicsDevice.SetRenderTarget(null);


1

Well.. sometimes you have to formulate a question and stop work until you find your answer yourself. In the evening I had some thoughts about resource management. We're talking about .Net ... thus a GC is involved. What if the finalizer thread comes along at a wrong time or state. Well - that would be actually a double fault. Not more right therefore, ...


1

So what you're doing is a pseudo-3D game then. The world works in 3D coordinates, but you just display stuff in 2D. To do things like these, you probably want to keep the character coordinates in 3D, and use these to calculate the sprite coordinates in 2D. It's totally up to you how you want your game to be controlled, but if for example, you use the X ...



Only top voted, non community-wiki answers of a minimum length are eligible