Hot answers tagged

4

Having a value deplete over time can be done a few different ways. The simplest is likely using the update method to deplete at a constant rate. public float myValue = 10; //the total public float subractPerSecond = 1; //remove this every second public void Update() { //subtract at a constant rate and ensure it stays at or above 0 myValue -= ...


3

It is very possible(with a quick refactoring), and you dont need to know the actual type, worry about deriving or need to instantiate every gameObejct manually in code. A simple trick with extension methods will do: just "add" a field and extension method to the GameObject class: public static class GameObjectExtensions { private static readonly ...


2

You can do something like this. It looks monumentally stupid (Unity has an awesome editor, why not use it?), but just in case you do have a good reason: You can't create scenes programmatically, but you can have an empty scene and add whatever you need programmatically. Using prefabs is probably not the best idea: prefabs are usually loaded only when ...


2

What you are looking for is a HingeJoint. Note that when you want it to start swinging, you need to give it a little push in form of a small impulse (like with AddForce on Start, for example).


2

Based on your description, I would make each card effect verb a class & then use composition to combine them into cards as needed. E.G. the draw cards action would be an effect class, its parameters might be # of cards, source drawn from & type of draw. Damage player might be another effect class & its parameters might be amount & ...


2

It isn't possible to prevent that, however you can get a call when the parent transform changes and set it back to the correct value. Transform m_DesiredParent; void Awake() { m_DesiredParent = transform.parent; } void OnTransformParentChanged() { if(transform.parent != m_DesiredParent) { transform.SetParent(m_DesiredParent); ...


2

For anyone looking for good network simulation software go here https://jagt.github.io/clumsy/ Clumsy doesnt need installed or anything, just run it and specify your parameters. I realise it is really simple but it is what I needed. Hopefully this helps.


2

No, not really, as the method is not virtual. The closest reasonable approach is to derive from GameObject and implement a new SetParent method: public new void SetParent (Transform transform) { throw new NotSupportedException("I'm afraid I can't do that."); } However, this will only fail at runtime and even then only if you call SetParent through an ...


1

Converting between a Quaternion (transform.rotation) and an Euler angle triplet is not possible the way you wrote it. See the API http://docs.unity3d.com/ScriptReference/Transform-rotation.html for the meaning of the transform.rotation property. If you want to double check or verify that your Euler angles are correct, you can convert them to a quaternion ...


1

Just to mention: Since I posted this question, I went on the official website to register as an "official" developer. I could get their approval in less than a month. I think the commercial situation of the WiiU is so bad that they are ready to let anyone try to make great games. But I still need to buy or rent dev material which is a bit expensive for ...


1

If you want to just have one GameObject for your character, you cannot add multiple Colliders of the same type to your GameObject and still have the ability to access all of them in your scripts (only the first in order of components would be accessible). However, you CAN add multiple Colliders of DIFFERENT types while still maintaining accessibility. In ...



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