Tag Info

New answers tagged

0

D3D11 will prevent you from binding a shader view of a resource and a render view of a resource simultaneously. Consequently you will need to bind and unbind the views every time you want to read or write to the depth texture; you can't just bind them and leave them that way for the lifetime of your program, because you can't have both views bound ...


0

This link will give you a starting point. http://www.codeproject.com/Tips/380152/Kinect-for-Windows-Find-User-Height-Accurately


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 ...


0

I study how Unity editor handles rotation with mouse movements. You can rotate by directly clicking on the object, but I didn't look too deeply to that rotation since it doesn't answer your question. You can hold the circular handles to rotate on only one local axis. It proceeds like this: It creates a line from the projection of the point clicked on the ...


0

You cann't draw one texture on front of the plane and different on back. Use twho planes with different winding order of vertices. You need to implement 4 vertices for create plane 0,0; 0,1; 1,0; 1,1 // Scale it as you wish For front plane use counter clockwise winding order when you creating it 0,0; 1,0; 1,1; 0,0; 1,1; 0,1 For back plane use ...


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);


0

I recommend a 3D models even though they will be super simple. You can texture all sides easily. You can also bend or morph those. Also lighting for effects or from the game table is possible if such things are required.


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 * ...


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 ...


0

Put simply, you only have the bare bones of a WinForms XNA based game. Your going to have to port your games code across from your XNA game project into your WinForms project. You'll have to create the MainLoop, and use it to call your MissileDisplay's Update and Invalidate Methods to simulate XNA's Update, and to call the GraphicsDeviceControl's Draw ...


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 ...


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. ...


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!).


0

If you are not already, you should use a shader to make all the pixels on your screen darker for night. You can draw a white circle (or a nice gradient circle) in a new render target at the appropriate position, then pass that render target as a Texture2D into the shader. In the shader you can use the extra texture as a "mask" (or whatever you would like to ...


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, ...


0

Suppose if you have a curve starting from (0,0) and lands at (100,0). If you only want to draw say 30% of the curve at end, then only draw the segment of curve between x=70 and x=100.


1

I think you and the commenters are on the right track. Ideally the hitboxes wouldn't have to be recreated on each attack (unless the nature of the attack were to change, maybe?). You could add something like this to every GameObject that can attack, along with a hitbox Collider marked as a Trigger. public class HitController : MonoBehavior { private Queue ...


0

The word is that the delegate{} syntax found in my previous answer is obsolete, there is another way of doing this using lambda notation: void buttonSetup(Button button) { //Remove the existing events button.onClick.RemoveAllListeners(); //Add your new event using lambda notation button.onClick.AddListener (handleButton); } void ...


1

Usually you will have your game engine alongside a rendering engine. The System which contains the Render Components will not do the drawing. It will ensure each Render Component is properly synchronised with the current animation, position etc... Concerning the rendering it will happen outside of your system in the render engine as you ...


6

It sounds like your intuition is correct and the components should be separate. However, I would look for better abstractions. For example, you say: "a base component class that figures out how to call each method" Putting Unity aside, this is something of a design anti-pattern (in OOP). You'll wind up with messy classes that don't have a clear purpose ...


0

Considering the age of this question, you likely have already found an answer, but I thought I would share my approach either way. Assuming your model has a convex shape, you can try pre-rendering the model's texture to a render target with a SpriteBatch, using the appropriate alpha value. Then apply that render target to your model. That way, you won't ...


0

I'm currently using the Visitor Pattern ( Wikipedia link) as the basis of my rendering system for my game. Basically, I have several interfaces defined to support this: (Note, this is basically an abstract recreation of part of my games system, and most likely does not reflect current code) interface ISystem { void Accept(EntityBase entity); void ...


2

This kind of defeats one of the main purposes of having components in the first place. What I think you actually want is something like this: class SpriteSystem { void SpriteSystem::Draw() { foreach(var sprite in sprites) { this.DrawSprite(sprite); } } } class Sprite { public Sprite::Sprite() { ...


0

From my short experience, these are my ideas/tips: What you are trying to do is called pixel perfect collision detection. Both player and texture should be inside a rectangle. Everytime Update function is called you should check "broad collision" to see if the two rectangles intersect (there is a Rectangle.Intersects method in XNA for rectangles) . If they ...


0

I wrote HLSL code for transparency and then I will transparent one image inside the body and another image used for my foreground : sampler stream : register(s0); sampler back : register(s1); sampler character : register(s2); float4 DepthToRGB(float2 texCoord : TEXCOORD0) : COLOR0 { // We can't easily sample non-normalized data, // Texture is a short ...


1

It worked after i replaced index=ArrayList.IndexOf(go,GameObject.Find (temp)); with index=System.Array.IndexOf(go,GameObject.Find (temp));


0

Since you're using Unity's terrain, you'll have to make some sacrifices. Unity's terrain is semi-procedural and stuck in the Z-Y plane, so you'll either have to: export the terrain data and import it into a third party terrain generator (I think Blender has a plugin for that) and then repaint the textures onto it. or change the scripts around to be in "top ...


0

Should have been: botInvadersRect[r, c].Y = (70 * r) + 24;


0

_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; _ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; extra references: System.Drawing , System.Windows.Forms


3

Maybe so? int dimensionX = monsters[0].AreaRect.Width; int dimensionY = monsters[0].AreaRect.Height; int monstersPerLine = 7; int padding = 10; int currentX = 0; int currentY = 0; int monsterIndex = 0; for(Monster monster : monsters) { if(monsterIndex % monstersPerLine == 0) { currentX = 0; currentY = currentY + ...


0

Are you looking to place objects in a grid? If so, just use a double for loop? for (int i = 0; i < desiredWidth ; i+= monster.width + paddingX){ for (int j ... ){ monster.x = i; monster.y = j; } }


1

Assuming your camera have a independent forward vector that always points from position of camera to the character; Suppose if you want to rotate the camera N radians in the local Y axis (character up) and maintains the same distance to target after the rotation: quat = axisAngle(target.up, radian); camera.forward = rotateByQuat(camera.forward, quat); ...


1

I would suggest trying Marching Squares to generate polygons from a binary image.


0

Do not new MonoBehaviour just add them as components. Your approach won't work. EDIT: I still you advise against breaking the componenten and Monobehviour approach. If you want testing have a look at the Unity Testing Tools. They will proved you with all you need including mocks and stubs for unit and integration tests. Asset Store Documentation


0

string str = "2, 4, 5, 7, 10"; string[] tokens = str.Split( new string[] {", "}, StringSplitOptions.None ); Use String.Split. You give it certain characters to "split" at and it returns the tokens. This isn't Unity specific, nor is it game development. But there's your answer. Next time try describing your problem to Google. You'll get your ...


4

What shapes are you using? If your shapes are convex (like circles, squares, rounded rectangles), you can just draw versions of different size and clip them to a triangle whose diagonal goes from upper right to lower left. I.e., zoomed in, light-to-dark: and dark-to-light: Then clip that: And then combine the two bezels: and finally draw the ...


0

You could get a bevel effect by underlaying the cells with upscaled graduated transparencies of themselves. This can also be used to get a glow effect.


4

You should just have one component for your laser. The source object would just have the laser component. The "redirect" object will have an additional component called redirect. The laser component casts a ray, if that ray hits an object containing a redirect component, the "redirect" object powers up its own laser. Think of the laser more as a trigger to ...


1

You need to either interpolate or extrapolate the collision. Basically this means instead of just checking the collision of the object where it is NOW, check the collision of the object with where it is and where it WILL BE or WAS, then check x number of times in between those positions. Vector2 pos = ball.position; Vector2 prevPos = ball.previousPosition; ...


1

What I've found more useful in Unity is to really take advantage of editor, and realise the fact that you're working towards a solution that is drag and drop able rather than flexible in code. An enemy movement in Unity could be represented by a single method, but I believe it would be much better, and much more to the style of Unity to have separate ...


0

Instead of changing the render mode of the canvas you could instantiate the 3d model and a Camera that points at it in an unused part of the scene (or set the Camera culling settings to only render the 3d model). That camera then renders to a texture that is used by an Image element in the alternate GUI. You'll need Unity Pro though.


1

Use a bool. Just have a boolean value that gets flipped when the first button is pressed: using UnityEngine; using System.Collections;![alt text][3] public class window : MonoBehaviour { private bool render = false; private bool redWindow = true; public Rect windowRect0 = new Rect(20, 20, 120, 50); public Rect windowRect1 = new ...


0

In your loop, you are using this overload: http://msdn.microsoft.com/en-us/library/ff433987.aspx, which instead of specifying a scale, specifies destination and source rectangles. It's hard to tell from the names you chose if you provided the correct rectangles, but you specified g_BotInvadersRect[r, c] as the destination (screen bounds) and ...


0

This will check whether every tile in a column has the same texture. You should be able to modify it to suit your needs. You also need to set up the board in the inspector. Set the board size to 5, then each column size to 5, then drag over all 25 gameObjects. using UnityEngine; using System.Collections; using System.Collections.Generic; public class ...


1

Set Game.Content.RootDirectory to the path you want and then just specify the file name portion. But keep in mind that you still have to include them in the Content project. If you don't want to/can't do that, then forgo the ContentPipeline altogether.


2

Dynamically importing and processing content at runtime is explained in the sample WinForms Series 2: Content Loading. This is the preferred method. You can also build an XNA Content Project file using MSBuild. this blog post explains how. You can create a temporary project file, so you don't need to modify or rebuild files in your Solution. Additional ...


0

In Visual Studio... Right mouse click on the Content Project Select 'Add' then 'Existing Item...' Navigate to the folder containing your content, change the filetype from the drop down box if needed, select your content file, then click on 'Add'. Use your content.


1

I'm fairly certain, though someone will no doubt prove me wrong, that you can not change individual elements in the mesh arrays of vertices, triangles, uvs etc. That is why when you work with procedural meshes you always update the entire array at once when you've finished modifying it. The reason for this is that mesh.uv gives you a copy of the mesh uvs ...


1

It looks like you have your score working using Time.time as the counter. I thought it may be helpful to explain what was happening when the code in your question is executed. When game starts and the Start() method runs it calls StartCoroutine (FeetScoreCounter()) When FeetScoreCounter() runs it immediately yields for one second, then after that delay it ...


0

This was the correct solution, where it converts score (float) to an integer.



Top 50 recent answers are included