Tag Info

Hot answers tagged

2

This question seems to be an X/Y problem. I think what you are really asking "how do I rotate a set of triangles?" You've settled on a very slow, very wrong solution to this problem. You should never be directly modifying vertex data on the CPU, unless you absolutely have to. I think your answer boils down to replacing: ...


1

Yes, you can configure your Lights to affect only certain objects, by using Layers. Assign your objects to a specific Layer (you can use an existing layer or define your custom one). Then, in Inspector pane, use Light's Culling Mask setting to set which Layers you want it to affect.


1

You are right that the correct function is Unproject. Try this: Vector3 modelPosition = graphics.GraphicsDevice.Viewport.Unproject( new Vector3(100.0f, 100.0f, 0.01f), // Note the 0.01f! effect.Projection, effect.View, Matrix.Identity); The 0.01f means you want a point that is 1% of the way between your near and far clip planes (the ...


1

The control variable is a static variable. The code you're looking at is for ensuring there's always a GameControl object in the world, and only one. The first time a GameControl object is loaded, control is set. If a GameControl is ever attempted to be loaded again, it will not match the already loaded control object and will be destroyed.


1

This is the implementation of a very simple version of a programming pattern called Singleton. For more context, see Unity Singleton Pattern. The basic idea is, the designer wants that there should only be one instance of the GameControl object. Therefore, before everything else (in Awake() function), the designer checks if the object is initialized or not. ...


1

I do this in my game by generating a distance field to a set of line segments, and using that as an additional mask on top of the radial one. Here's how its done: Generate N pairs of random points and connect them together as line segments. For each pixel in the mask, determine the distance to every line segment. Take the min over all segments, called d*. ...


1

So long as the SpriteSortMode is SpriteSortMode.Immediate you can make alterations to graphics device in between draw calls which allows you to change the ScissorRectangle, RasterizerState, SamplerStates, ect... Of course you lose the performance optimization from the batching; however, it is sometimes worth it if the alternative is creating many begin/end ...


1

If your testTextureArray[i] is pointing to the same texture, you should have the same performance, but if not, then you are just hitting a design restriction of SpriteBatch. Most implems of SpriteBatch I'm aware of (at least, XNA, SharpDX, Paradox, DirectXTk... though, don't know for sure about MonoGame...) are trying to batch draws with the same ...


1

You may want to look into this and this. Unity makes it really easy. The scripting reference is your best friend. Something like the following: if (Input.GetKeyDown(KeyCode.LeftArrow)) transform.rotation = Quaternion.Euler(0, 30, 0); else if (Input.GetKeyUp(KeyCode.LeftArrow)) transform.rotation = Quaternion.identity;



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