Tag Info

Hot answers tagged

7

You can simply get the vector pointing in the right direction, then scale it by the distance you want and add that to the initial point. This will define a new end point for your line. //Get the direction of the line Vector3 direction = point_B - point_A; //Get a new point at your distance from point A Vector3 point_C = point_A + (direction.normalized * ...


3

If you know the start and end points as well as the desired length, you can use Vector3.Lerp Vector3 midPoint = Vector3.Lerp(startVector, endVector, 0.5f); Debug.DrawLine(startVector, midPoint);


2

This falls under the Single Responsibility Principle (see SOLID). Specifically: the spawn point should handle entity creation, rather than a manager you would want to either have a field on the spawn point or a parameter on the spawn method that would tell it what to spawn you would then use an ordinary trigger behavior (maybe called TriggerSpawn, with a ...


2

It's simply a floating point precision error and the reason why you shouldn't use float whenever you really care about precision (and try to avoid using direct comparison with them). Use double instead (but it has limited precision as well!).


2

Other than to specify that "only one" is called, Unity does not guarantee any behavior in this case. The most likely scenario, which you can determine through experimentation, is that either the first RPC that becomes registered/known to the system is called, or the last one is. However, this is an implementation detail. Unity explicitly does not want you ...


1

http://docs.unity3d.com/ScriptReference/Ray.html This shows us that ray takes 2 parameters; an origin( the place the ray is being cast from ), and a direction. This is where your code is wrong, you pass in the enemy position for an origin, and pass in the player's position for the direction. A direction should be a normalised vector. To get the direction ...


1

You can use Blend Trees to change animation speed. First of all you should add float parameter to Character Controller. Then create Blend Tree and double click on it. It'll open Blend Tree editor. Select Blend Type 1D and select created float parameter. Add 5 same animations of reloading. Each animation in Blend Tree has two parameters: Threshold and Speed. ...


1

I regularly use RPC like the following: { //Send all the ship components to other clients NetworkViewID viewID = ship.GetComponent<NetworkView>().viewID; foreach(ModuleDefinition module in ship.GetAllModuleDefinitions()) { networkView.RPC ("AddShipModule", RPCMode.Others, viewID, netOwner, ...



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