Tag Info

Hot answers tagged

17

Keyboards have hardware limitations on how many keys can be pressed and recognized at the same time. Your code is not the problem here, it's most likely the design of the keyboard.


10

Keyboards have a key matrix, where the buttons have been arranged into something roughly square, with the keyswitches each being tied to one row and one column. The keyboard activates each row and then reads the columns. If you sketch this out you will see that some button combinations must activate "phantom" keys. You can fix this with one diode per button ...


5

I'd like to separete these things due to clearity reasons but I wonder if calling different FixedUpdate() functions would imply some kind of issue. For example: is their execution ensured to be called sequentially or they could run asincronously? Each callback of each MonoBehaviour will be called exactly once for each update loop, but you haven't ...


4

There's no built-in way to do that. If you prefer an event based solution you can wrap all input polling inside a component and expose the relative and subscribe for them. Some like: public EventHandler : MonoBehaviour { public event Action<Vector2> mouseCliked; void Update() { if (Input.GetMouseButtonDown(0)) { ...


3

I see your problem, so let's run through the code here. At the start, you say there are (1440 * 60) seconds in a day, but then you proceed to define the number of hours in the day, the number of minutes in an hour, and the number of seconds in a minute. It works when the numbers are correct, but let's go through the logic of what happens if you define 600 ...


2

Notice in that documentation the optional last parameter: BuildTarget targetPlatform = BuildTarget.WebPlayer In other words, if you don't explicitly set the target platform then it will default to target web player. To make it target the current platform, tell it: EditorUserBuildSettings.activeBuildTarget Frankly, I would file this as a bug against that ...


2

_hourLength = _dayLength / HoursToTheDay; //determines how long an hour is _minuteLength = _hourLength / MinutesToTheHour; //determines how long a minute is _secondLength = _minuteLength / SecondsToTheMinute; //determines how long a second is Could be all that. Integer division results in integers, and you didn't supply enough code to know what type ...


2

Your png is most likely not set to be imported as a sprite, and the property you want to use it in requires a sprite (background, checkmark and the others are by default sprites). Click on your png to open up the import settings. The Texture Type dropdown menu is the interesting part here. Set it to Sprite, apply the changes and your sprite-ified png should ...


1

The first parameter in Invoke takes only the name of the method you wish to call. Assuming PositionScript.instance is set to a MonoBehaviour component of some sort: PositionScript.instance.Invoke("MAttack",5f);


1

I am not quite sure what you are not understanding here, but I attempt to answer your question anyway. I am not quite getting what that does or what purpose it serves. In cases where you do not fill in the fields in the inspector (which requires them to be public), you need to find the instances of the needed components in code. The ...


1

An easy way if it is a simple animation (rotating gear, a piston, etc) would be to edit your animation to be exactly 1 second long then use the Animator.speed and set it to 1.0f / wanted_seconds, but that's not usable for complex character animations. You can figure out the length of the AnimationClip ( ...


1

The goal of sprite sheets is to reduce the number of texture bindings. As you probably need to bind different textures (other than your animations) during a single frame you'll always have at least one texture bind to select one of the spritesheets back on the next frame. Whichever texture your bind on the next frame will have the same penalty as the data ...


1

The simplest, modestly realistic, model I can think of would be parameterized by the following: Mz The Turning Moment of the ship about the steering (ie Z or yaw) axis; L/2 The distance of the rudder from the turning axis, approximated as 1/2 the ship's length L; v The current linear velocity of the ship (relative to the water, not the land nearby, ...


1

As said by Heisenbug is no built-in way to do this. My recommendation is to explore the UnityEvent namespace new to Unity 4.6 and above. This will allow you to expose functionality to designers that will allow them to rig up interesting inputs and receivers. You can go the extra mile and implement a custom editor with a serialized dictionary and button to ...


1

Go to Component / Rendering GUIText ;)


1

If a in-game day is 10 minutes in real life, you just need to get the number of seconds since the last 10 minutes and add a ratio to convert it to a 24 hours format. Get the number of seconds from the last 10 minutes. realTimeSecondsSinceTheLast10Minutes = (Minutes % 10) * 60 + seconds; Get the ratio between a 10 minutes day to a 24 hour day ratio = ...


1

Normally, once the project is build, if you target windows platforms you will get a dialog to select the resolution at startup. This is optionally since you can disable it and create your own mechanism for managing screen resolution at runtime using the provided API Screen.SetResolution.


1

If you have the gameobject with the code attached selected, you can drag the gameobject in the scene using the hierarchy to the inspector. Confusing I know, here is a picture: EDIT: Strike that, this is more accurate: With unity, you can not reference things in the hierarchy from a prefab. You need to somehow add it at runtime. A cheap way to do this is ...


1

Your tilt line is stomping over whatever rotation the drone had and applying a new one. Just like writing: variable_a = 42; will replace whatever value was in variable_a before, the same happens with rotations, unless you use some type of combining operator like multiplication or Lerp. To fix this, you can build a rotation that takes both inputs into ...


1

I usually use a transform hierarchy like this: Entity Object -> Visual -> Collision The "Entity Object" is at unit scale (1,1,1) and contains the rigidbody and whatever the "main script" for a particular entity is. This keeps the inspector clean and means the transform viewed by the main script is predictable. The Collision object is also kept ...


1

The "tint" color is a color that gets modulated (multiplied) with the texture color. This color is used with sprites for effects like making the player sprite blink red when hit by an enemy. To do so, you could set the tint to red when the player gets hit and leave it red for a couple frames, them restore it to white. Do that repeatedly for a few seconds and ...


1

If you want to have a shared leaderboard for all players, then PlayerPrefs is not what you want. It's designed to save a file to the player's local computer, which only they can access. For a global leaderboard, you'll need to implement a server-side component for the game to communicate with. This page on the Unity wiki might be helpful to get you started. ...


1

A couple days of googling, testing, coding and I have it all figured out. 1. Shadows on Sprites.. There is a work around to having sprites cast and receive shadows. This thread in the unity forum has a way to do it with sprites: http://forum.unity3d.com/threads/why-cant-sprites-gameobjects-cast-shadows.215461/ The other way is to create your own sprite ...



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