texts: Unity Vector3 y and z Components being set 0

texts:
So I'm working on an RTS game and I'm trying to set pre-defined positions for units using my own formula. It takes the list of units and makes a position for each one in an array. The array then goes through a for loop which offsets each x position so units don't collide. The problem is that the Y and Z components are set to 0 whenever I try to get them to move. I'm not sure why because I'm not touching them.

Here it is:

Selected units list if you needed it

    public static List<GameObject> SelectedUnits;

    void MakeFormation(RaycastHit hit)
    {
        Vector3 origin = hit.point;
        float Separation = 10f;
        Vector3[] positions = new Vector3[SelectedUnits.Count];

        for(int i = 0; i < positions.Length; i++)
        {
            positions[i].x = origin.x+Separation*i;
        }
        MultiSelect(positions, origin);
    }

And the function that actually gets the units going

    void MultiSelect(Vector3[] positions, Vector3 origin)
    {
        Debug.Log(SelectedUnits);
        if (SelectedUnits.Count > 0)
        {
            for (int i= 0; i < positions.Length; i++)
            {
                Debug.Log("Moving group to area: " + positions[i].ToString("F4"));
            }

            for(int i=0; i< SelectedUnits.Count;i++)
            {

                Debug.Log("Index: " + i);
                SelectedUnits[i].GetComponent<NavMeshAgent>().SetDestination(positions[i]);
            }
        }
    }
```


texts:
I'm writing a networked iOS game.  When sending packets with GKMatchSendDataReliable (which I assumed was UDP with their own packet reception code written) at 60 packets per second (so 16 ms between adjacent packets), average ping times rapidly get worse:  I opened 7 GameCenter matches below (one after the other) and simply sent a "flood" of 100 packets (at a rate of 60 packets per second).  I measured the average roundtrip time, and these are the results:

[ 21:16:39 ]:  I saw an average roundtrip time of 52.342787 ms, he saw 54.496590 ms
[ 21:16:34 ]:  I saw an average roundtrip time of 62.631942 ms, he saw 61.991655 ms
[ 21:16:45 ]:  I saw an average roundtrip time of 88.394380 ms, he saw 83.619123 ms
[ 21:16:51 ]:  I saw an average roundtrip time of 179.053118 ms, he saw 156.869141 ms
[ 21:16:57 ]:  I saw an average roundtrip time of 75.025076 ms, he saw 75.419723 ms
[ 21:17:23 ]:  I saw an average roundtrip time of 8832.082488 ms, he saw 7616.877558 ms
[ 21:19:33 ]:  I saw an average roundtrip time of 25088.962344 ms, he saw 16833.064914 ms

After the last 2 tests the results are around 1000 ms.

It would seem that I'm being throttled, most likely by my ISP.  Because this is an iOS game, people will use regular residential connections.

When I changed the packet send rate to being 10 times slower (so 1 packet every 160 ms), the tests take much longer, but roundtrip times remain consistently low.

  [ 21:31:27 ]:  I saw an average roundtrip time of 55.289109 ms, he saw 69.032727 ms

So it looks like to keep low latency on the connection (and not be "punished" by ISPs) I have to reduce the rate of packets that I send.  Keep in mind these are very small packets, like 40 bytes maximum, yet I'm still being throttled.

I'm looking for guidelines on how many UDP packets I can send per second to avoid being throttled!  Are there any general guidelines anywhere?


texts: Load 2 triangles in a simple DX11 example

texts:
I'm following this tutorial, where they show how to setup a simple dx11 demo with a green triangle in the middle. I'd like to be able to modify it so that it shows 2 triangles instead, i modified the code of the Graphicsclass.cpp in the tutorial by adding some lines to the Render() function, just after the first triangle is drawn, it's the //ADDITIONAL CODE section:

[...]
// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
m_Model->Render(m_Direct3D->GetDeviceContext());

// Render the model using the color shader.
result = m_ColorShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix);
if (!result)
{
    return false;
}

//ADDITIONAL CODE
// Reset the world matrix.
worldMatrix = XMMatrixIdentity();

// Translate to the location of the second triangle.
translateMatrix = XMMatrixTranslation(1.0f, 1.0f, 0.0f);
worldMatrix = XMMatrixMultiply(worldMatrix, translateMatrix);

// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
m_Model->Render(m_Direct3D->GetDeviceContext());

// Render the model using the color shader.
result = m_ColorShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix);
if (!result)
{
    return false;
}
//END OF ADDITIONAL CODE
// Present the rendered scene to the screen.
m_Direct3D->EndScene();

But the second triangle doesn't show up, i also put the complete example on github in case you want to try it yourself. I'm sure i'm missing something pretty basic but i can't figure it out


texts: How to create smoke that spreads outward in all directions?

texts:
I saw many tutorials about smoke grenade but they just use volumetric smoke. I want to make something like the smoke grenade in PUBG, where the smoke spreads in all directions; how to do that?

The Unreal Engine 4 smoke grenade throws out smoke in a particular direction, like this:

But I want something more like PUBG's that spreads smoke evenly in all directions:


texts: Aligning animation frame assets with different sizes

texts:
I have code that changes texture in each frame depending on the player's state - walking, idle.

My problem is that the idle texture (from separate png) has a slightly different size, and due to that it appears not in line with rest of the animations, seemingly being in a slightly different position when returning to idle.

How can I position the frames based on the center of texture instead of the bottom left?

batch.draw(determineTexture(), position.x, position.y,
            currentFrame.getRegionWidth()/2f, currentFrame.getRegionHeight()/2f,
            currentFrame.getRegionWidth(), currentFrame.getRegionHeight(),1f,1f, rotation,false);

TextureRegion determineTexture(){
        if(playerState == State.idle)
            currentFrame = idleAnimation.getKeyFrame(stateTime, true);
        else if (playerState == State.walkingUP || playerState == State.walkingDOWN || playerState == State.walkingRIGHT || playerState == State.walkingLEFT )
            currentFrame = walkAnimation.getKeyFrame(stateTime, true);
        return currentFrame;
}

One png has a height of 57 - idle, while 6 columns and one row of walking frames have a height of 87 pixels.


texts: Constant rotation of a revolute joint in box2d

texts:
I would like to have a line with one end attached to a location and have it rotate constantly (with the same speed) with a maximum of 45 to -45 degrees (i.e. I would like to have it swing like a rope back and forth 90 degrees).

Is this possible or should I use non box2d objects to do this (cheat box2d engine)?


texts:
I'm planning to build a big browser multiplayer game with gameplay very similar to agar.io but rpg.
Game will be containing rooms as It's done in agar.io. 50-100 players max per room. Realtime. 10ms update loop.
The server should be scalable, I guess the kafka or some other message broker should be used, but I can't figure out how to design such system to handle 2000-10000 players per day at least or more.
Where player's state should be calculated?If I create websocket server and create single loop It cannot handle such huge bunch of players. How to split player sessions to kafka consumers or to do something to Improve performance in scalable calculation model?
Any thoughts regarding the server architecture will be appreciated!


texts:
I have a prefab with a particle system attached. In the code I play the particle by using this code

            ps.enableEmission = true;

When i run the game, and that code executes, the particle emitter does not emit anything in the "game" window unless i press simulate button in the "scene" window.

Anybody knows why?


texts:
So I wanted to make my menu fade in when the game starts and fade out when it quits. To do so, I created a second surface and planned to fill it with black and then gradually increase alpha. So in the constructor I added:

    self.fadeInSurface = pygame.display.set_mode(screen_size, flag)

In the main game method before the game loop starts:

self.fadeIn()

And the aforementioned fadeIn() looks like this:

def fadeIn(self):
    for i in range(100):
        self.fadeInSurface.fill((0,0,0))
        self.fadeInSurface.set_alpha(i)
        self.clock.tick(30)
        pygame.display.flip()

But instead of a fade-in, all I get is solid black screen for a short time and then the menu appears without any eye candy whatsoever. What am I doing wrong?

EDIT: Thanks to @Heckel, I made something like this:

def fadeIn(self):
        for i in range(255):
            self.surface.blit(self.background, (0,0), None, BLEND_RGB_MAX)
            self.surface.blit(self.curStart, (100,200), None)
            self.surface.blit(self.curQuit, (400,350), None)
            self.fadeInSurface.fill((0,0,0))
            self.fadeInSurface.set_alpha(255-i)
            self.surface.blit(self.fadeInSurface, (0,0))
            self.clock.tick(30)
            pygame.display.flip()

so that I have the main surface (called surface) on which I project my buttons and background and a secondary surface (called fadeInSurface) which is solid black but its alpha changes. Running this code, however, still results in solid black screen for a few seconds and then a sudden change to full clarity of the whole menu :( Why is that so?


texts: XNA Access violation from KernelSoundEffectInstance

texts:
Some users (but not all) are reporting a periodic crash in my XNA game. They say it's happening every 15 to 20 minutes. I am unable to replicate this myself, so I asked users to send me error logs.
Here is the error log one user gave me which reported an access violation:

Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

at Microsoft.Xna.Framework.Audio.KernelSoundEffectInstance.SetVolume(KernelSoundEffectInstance* , Single volume)
at Microsoft.Xna.Framework.Audio.SoundEffectUnsafeNativeMethods.SetVolume(UInt32 soundEffectInstanceHandle, Single volume)
at Microsoft.Xna.Framework.Audio.SoundEffectInstance.set_Volume(Single value)
at Game.DynamicSong.Update()
at Game.DynamicMusicPlayer.Update()
at Game.Game1.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Microsoft.Xna.Framework.Game.Run()
at Game.Program.Main(String[] args)

Important note: My game dynamically fades music in and out depending on what you're doing and where you are. So I'm calling volume-related methods on looping music multiple times every update. I can't see how this could cause such an error though.

So do you think this is an error on my part or is it a bug with XNA?
How could I go about fixing this or getting around it?

Would it be safe (or even possible) to just not close the program when this exception is thrown? (probably not?)

Thanks in advance.

Update: Users are reporting that the log is identical for each crash. This means it's always happening in the KernelSoundEffectInstance class. Prior to this I was worried it may be happening in different places each time, like this person here: https://stackoverflow.com/questions/4074585/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-ot


texts: "Walking" along a rotating surface in LimeJS

texts:
I'm trying to have a character walk along a plank (a long, thin rectangle) that works like a seesaw, being rotated around a central point by box2d physics (falling objects). I want the left and right arrow keys to move the player up and down the plank, regardless of it's slope, and I don't want to use real physics for the player movement.

My idea for achieving this was to compute the coordinate based on the rotation of the plank and the current location "up" or "down" the board.

My math is derived from here:
https://math.stackexchange.com/questions/143932/calculate-point-given-x-y-angle-and-distance

Here's the code I have so far:

movement = 0;
if(keys[37]){ // Left
    movement = -3;
}

if(keys[39]){ // Right
    movement = 3;
}

// this.plank is a LimeJS sprite.
// getRotation() Should return an angle in degrees
var rotation = this.plank.getRotation();

// this.current_plank_location is initialized as 0
this.current_plank_location += movement;

var x_difference = this.current_plank_location * Math.cos(rotation);
var y_difference = this.current_plank_location * Math.sin(rotation);

this.setPosition(seesaw.PLANK_CENTER_X + x_difference, seesaw.PLANK_CENTER_Y + y_difference);

This code causes the player to swing around in a circle when they are out of the center of the plank given a slight change in rotation of the plank.

Any ideas on how I can get the player position to follow the board position?


texts:
It seems to be answers.unity.com not working for a couple of days, so I ask my question here.

Well, I'm using Unity and I have two objects (A and B). Object A is a parent of object B and object B is rotating around object A executing RotateAround function.

And everything is fine until I rotate the  object A. In this situation I get a mess I can't explain because of lack of geometry knowledge.

But I have to be able to rotate object A with object B keeps its round ecliptical orbit around object A.

How can I do it in code?..

Sorry for a messy question and bad English. Hope those pictures help to understand what I want. Thanks to you all.


texts: I used NGUI 2 and NGUI 3 for our UI. Now want to upgrade to Unity 4.6 and migrate all NGUI to Unity UI. Is there any tools? What's the best practice?


texts: How to disconnect all signals of an emitter?

texts:
This a follow-up question of this one
I want to disconnect multiple signals before using queue_free().
In docs we have:
void disconnect ( String signal, Object target, String method )

Is it possible to disconnect all signals of an emitter without using the names of the signals or methods involved?


texts: In Unity, how do I set the window's size?

texts:
Say I want a "world map" (maybe think the overworld in ff games) with dimensions 800px by 600px. How would I do that? Is this tied in with the resolution? Because I know you can set the game aspect.

Tutorials don't seem to cover this. For example, in this video, he just sort of drops the sky into the scene. You can see that some parts of the sky is cut off. He fixes this later by setting the pixels to units to 200 instead of 100. However, this all seems arbitrary to me. We don't know how large the sky is now, ie we don't know the dimensions of the sky. How do people fix this problem? Do you just look at the original image and do math to figure out how "large" it is in unity? What happens if you do something like this video where no size is defined?


texts: 2D simulating light sources (subtract a texture from an other)

texts:
I want to simulate a night and day cycle with SFML (plain 2D, no shadows). What I want is to get a smooth transition from day to night, and during night having some lights "on".

So the approach I've thought is adding a black layer on top and change its transparency with time, that gives the effect I'm looking for. For adding lights I can crop out circles out of that layer

sf::CircleShape lightCircle(200);
lightCircle.setFillColor(sf::Color(255, 255, 255, 1));

sf::RenderTexture renderTexture;
renderTexture.create(/* view size */);

while (window.isOpen()) {
  // ...

  // update light
  renderTexture.clear(sf::Color::Black);
  renderTexture.draw(lightCircle, sf::BlendNone);
  renderTexture.display();

  // draw
  window.clear();
  window.draw(sf::Sprite(renderTexture.getTexture()));
  window.display();
}

Now, what I would like to do is use my own image instead of a CircleShape. Say a circle or a cone with fading borders, some more realistic than just a circle. Like

I have tried with sf::Image and createMaskFromColor but I'm not able to handle the fading edges.

How can I get that?

Am I in the right path or is there a simpler approach?


texts:
I have a game in which there is a cat that has three states: On Ground, Going Up and Coming down.

This is handled by having 3 states, up,ground and down. Now, there is an additional requirement that the cat picks up a power up and becomes invincible. In this special state, the cat doesn't die if it falls through gaps etc. In this state also, there are same animation states : up, ground and down. However, when the cat is in this special state, it's sprite changes to a starry,shiny sprite.

So now we have two sets of animations : one normal, another power up. How can I manage these two sets?


texts:
I am trying to make a doorway that is 2 tiles high.
I have created an item called, Door Key. But I want both event tiles To hide or remove when I use the Door Key. The problem is I have to create two events to cover the doorway but can only get 1 event to change. So is there a way to change 2 events at once?


texts:
I have a game in XNA, I want to connect this game with WindowForm to show for example the distance and the position.

I tried to apply many tutorials that talking about this.
but here is my problem :

It's empty!!
How can I show my game.

I think my problem is here :

using Microsoft.Xna.Framework;

namespace MissileProject.CustomForms
{
    public class MissileDisplay : WinFormsGraphicsDevice.GraphicsDeviceControl
    {
        protected override void Initialize()
        {

        }

        protected override void Draw()
        {
           GraphicsDevice.Clear(Color.CornflowerBlue);
        }
    }
}

Any help or advice please ?


texts:
Just wondering what people nowadays use for developing Commodore 64 Games?

I've got the Programmer's Reference Guide which goes into all the details, but in the modern Age I assume I won't have to do development on an actual C64 itself?

Are there tools that run on Windows or Mac OS X that are a bit like an IDE that offers some help and some debugging facilities (e.g., by hooking into an Emulator) or easy packaging into .d64 disk images?

Is 6502 Assembler the one chosen language, or is C development feasible? (Ignoring BASIC here)


texts: 2D platformer multiple rectangle collision cause jitter

texts:
I posted this question two weeks ago: 2D platformer corner collision and I implemented NoobsArePeople2's solution.

Problem is, when player intersects two rectangles that are inside each other, he starts jittering. I don't know how to describe it so I made a video: http://www.youtube.com/watch?v=2AYUGeuxM0c

In the first 4 or so seconds, you can see that when he collides with two rectangles that arent in each other or touching each other, everything works fine, but in the rest of the video, you can see that when player touches side, he starts to jitter (please note that because of fraps, my game was running at quarter of FPS I normaly have, so without fraps the jitter is much faster)

To give you idea how my collision rectangles look now, here is debug mode (each rectangle is randomly colored)

I have couple of algortihms in place that merge rectangles into one (still need to do some work on that), but some simply cannot be merged. One example is the C object on the right. Right now it is made of 7 rectangles (will be 3 after I complete my algorithm) and when player slides on side of it, he starts to jitter.

I suspect problem is in my gravity, but Im not sure. I've spent 5 days on trying to fix this and Im lost.

Heres my code (slighty modified from platformer sample):

        for (int i = 0; i < playerCollisionRectangles.Count; i++)
        {
            Vector2 depth = Collision.GetIntersectionDepth(player.PlayerRectangleInWorld, playerCollisionRectangles[i]);
            if (depth != Vector2.Zero)
            {
                float absDepthX = Math.Abs(depth.X);
                float absDepthY = Math.Abs(depth.Y);

                // Resolve the collision along the shallow axis.
                if (absDepthY < absDepthX)
                {
                    // Resolve the collision along the Y axis.
                    player.PlayerPositionY += Convert.ToInt32(depth.Y);
                }
                else
                {
                    // Resolve the collision along the X axis.
                    player.PlayerPositionX += Convert.ToInt32(depth.X);
                }
            }
        }

And here is my gravity code (very very simple):

        if (Gravity)
        {
            //for camera
            position.Y += 2;
            //position in world
            playerPositionY += 2;
        }

And lastly here is one of my methods to move player (i have similiar methods to move him left and up):

    public void MoveRight()
    {
        animate.Enabled = true;
        animate.Row = 0;
        position.X += speed;
        playerPositionX += speed;
    }


texts: Set multiple render targets with OMSetRenderTargets using ComPtr

texts:
I've recently decided to get rid of pretty much all of the raw pointers from my Direct3D code, and I ran into a problem with using ComPtr<T> template with multiple render targets.

Microsoft suggests using ComPtr<T> for D3D instead of unique_ptr<T> or shared_ptr<T>. However even their example shows how to use it with OMSetRenderTargets, but I couldn't really find anything how to use it when you have to bind an array of managed objects.

Here's some code of my current solution:

class Texture{
public:
    void Initialize(const Bitmap &bitmap){ /* ... */}

    ID3D11ShaderResourceView* GetShaderResourceView() const { return this->m_pResourceView; }
    ID3D11RenderTargetView* GetRenderTargetView() const { return this->m_pTargetView; }
    ID3D11Resource* GetTextureResource() const { return this->m_pTexture; }

    ID3D11Texture2D* GetTexture2D() const { return static_cast<ID3D11Texture2D*>(this->m_pTexture); }

private:
    ID3D11ShaderResourceView * m_pResourceView;
    ID3D11RenderTargetView * m_pTargetView;
    ID3D11Resource * m_pTexture;
}

class Renderer{
public:
    void Initialize(const Window & targetWindow){ /* ... */ }

    void SetDepthStencilView(ID3D11DepthStencilView* pDepthStencilView = nullptr){
        n = n < RENDER_TARGET_MAX ? n : RENDER_TARGET_MAX;
        if (!n && pRenderTargetView == nullptr) {
            m_renderTargetViews[0] = m_myRenderTargetView;
        } else {
            m_renderTargetViews[n] = pRenderTargetView;
        }
    }

    void SetRenderTargetView(ID3D11RenderTargetView* pRenderTargetView = nullptr, size_t n = 0){
        if (pDepthStencilview == nullptr) {
            m_depthStencilView = m_myDepthStencilView;
        }
        else {
            m_depthStencilView = pDepthStencilview;
        }
    }

    void ApplyRenderTargetView(size_t count = 1){
        m_renderTargetViewCount = count < RENDER_TARGET_MAX ? count : RENDER_TARGET_MAX;
        m_deviceContext->OMSetRenderTargets(m_renderTargetViewCount, m_renderTargetViews, m_depthStencilView);
    }

private:
    ID3D11Device* m_device; // device context, swap chain, raster state, etc ...
    ID3D11RenderTargetView* m_renderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT], *m_myRenderTargetView; // This is the screen as a default
    size_t m_renderTargetViewCount;
    // depth stencil buffer, etc ...
}

void some_use_case(Renderer & render){
    Texture colorMap;
    Texture normalMap;
    Texture positionMap;

    render.SetRenderTargetView(colorMap.GetRenderTargetView(), 0);
    render.SetRenderTargetView(normalMap.GetRenderTargetView(), 1);
    render.SetRenderTargetView(positionMap.GetRenderTargetView(), 2);

    // ... Render geometry
    // ... Render posteffects
}

Keep tracking and releasing all of the resources are way too tedious, and It's reasonable to introduce some smart pointer solution here. How could I replace the pointer definition, and how could I bind it m_renderTargetViews to OMSetRenderTargets?


texts: XNA / Monogame Camera flickering on collision

texts:
I have my camera follow my player and it works perfectly, I had some issues with collision and managed to get it working, but now my camera follows my player when it gets pushed back so the camera just flickers when holding down the button towards a collision since it's following the player! I tried to stop the camera from following the player on an axis when colliding with something but it still makes the character look weirdly bouncing from walls. This is my code:

Camera Updating

if (player.CameraFollow)
{
    Camera.IsFollowingObject = true;
    if (Camera.IsFollowingObject)
    {
        Vector2 relativePlayerpos = -player.CurrentPos;
        relativePlayerpos.X += Camera.Viewport.Height;
        relativePlayerpos.Y += Camera.Viewport.Width/2 - player.Sprite.SourceRect.Height/2;
        Camera.Pos = relativePlayerpos;
    }
}

Collision Handler

public void CollisionHandler(ref Player player, Rectangle tileRect)
{
    //push left
    int left = Math.Abs(tileRect.Left - player.CollisionBox.Right);
    //push top
    int top = Math.Abs(tileRect.Top - player.CollisionBox.Bottom);
    //push right
    int right = Math.Abs(tileRect.Right - player.CollisionBox.Left);
    //push bottom
    int bottom = Math.Abs(tileRect.Bottom - player.CollisionBox.Top);

    if (left < top && left < right && left < bottom)
    {
        player.Velocity.X = 0;
        player.Sprite.Position.X -= left;
    }
    else if (right < top && right < left && right < bottom)
    {
        player.Velocity.X = 0;
        player.Sprite.Position.X += right;
    }
    else if (top < left && top < right && top < bottom)
    {
        player.Velocity.Y = 0;
        player.Sprite.Position.Y -= top;
    }
    else if (bottom < left && bottom < right && bottom < top)
    {
        player.Velocity.Y = 0;
        player.Sprite.Position.Y += bottom;
    }
}

This is what the collision basically does:

Any help is appreciated, thank you!


texts: Applications programmer - Where to start?

texts:
So far I've done web design/development and applications programming and of course video games has always been one of those things that I've wanted to take a stab at but never tried outside of a few minor and failed incursions. The only notable game programming I can say I have done was a little puzzle-ish game for the NES written in 6502 assembly so that doesn't exactly count for much.

Basically, what would be a good jumping off point for me? I do know C++ and Java if that gets me anywhere.


texts: The best algorithm enhancing alpha-beta?

texts: I'm studying AI. My teacher gave us source code of a chess-like game and asked us to enhance it. My exercise is to improve the alpha/beta algorithm implementing in that game. The programmer already uses transposition tables, MTD(f) with alpha/beta+memory (MTD(f) is the best algorithm I know by far). So is there any better algorithm to enhance alpha-beta search or a good way to implement MTD(f) in coding a game?


texts: How do I make the ui button to move my character?

texts:
How do I make my character move left,right and jump when click ui buttons using this code?

using UnityEngine;
using System.Collections;

public class Player: MonoBehaviour {

public float maxspeed = 10f;
bool facingRight = true;

Animator anim;

bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public Vector2 jumpDirection = new Vector2(1f, 1f);
public Vector3 groundCheckOffset = new Vector3(0f, -1f, 0f);
public float jumpFocre = 500f;
bool doubleJump = false;

void Start ()
{
    anim = GetComponent<Animator> ();
}

void FixedUpdate () {
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
    grounded = Physics2D.OverlapCircle(transform.position + groundCheckOffset, groundRadius, whatIsGround);
    anim.SetBool ("Ground", grounded);

    if (grounded)
        doubleJump = false;

    float move = Input.GetAxis ("Horizontal");

    anim.SetFloat ("Speed", Mathf.Abs (move));

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
}
void Update()
{

    if((!doubleJump) && Input.GetKeyDown ("up"))
    {
        anim.SetBool("Ground", false);

        float move = Input.GetAxis ("Horizontal");

        jumpDirection.x = move;
        GetComponent<Rigidbody2D>().AddForce(jumpDirection.normalized * jumpFocre);

        if(!doubleJump && !grounded)
            doubleJump = true;
    }

}

    void Flip()
{
    facingRight = !facingRight;
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
}
}


texts: Custom List Editor dependent on data from separate class's data

texts:
I want to make a custom inspector that I'm not really sure how to approach. The idea is I have a quest framework with a class that holds onto the quest data and another class that is intended to hold onto dialogue data. The quest system is agnostic of my dialogue system.

I want to be able to display the quest and dialogue data this way:

QuestName0

DialogueGiveQuest (TextAsset field)
DialogueQuestIsActive (TextAsset field)
DialogueQuestIsComplete (TextAsset field)

QuestName1

DialogueGiveQuest (TextAsset field)
DialogueQuestIsActive (TextAsset field)
DialogueQuestIsComplete (TextAsset field)

etc...

Here's a pseudocode class layout

public class QuestData : MonoBehaviour
{
    List<Quest> quests;
}

public class DialogueData : MonoBehaviour
{
    public TextAsset dialogueGiveQuest;
    public TextAsset dialogueQuestIsActive;
    public TextAsset dialogueQuestIsComplete;
}

public class Interaction : MonoBehaviour
{
    QuestData questData;
    List<DialogueData> dialogueData;
}

[CustomEditor(typeof(Interaction))]
public class InteractionEditor : Editor
{
    public override void OnInspectorGUI()
    {
        var interactionData = (InteractionData)target;
        //foreach interactionData.questData.quests
          // draw quest name
          // make sure there's a dialogueData element for each quest
          // draw field for each DialogueData
    }
}

An obvious issue is dialogueData doesn't care about what's going on with questData.quests so if the inspector were to draw normally it would display 2 lists. I'd like the dialogue data to add and remove elements to itself depending on the quest data but that sounds like it be a real challenge to serialize.


texts: Cancel a SpriteBatch I've started drawing

texts:
Background:

I'm working on a control library for XNA to use in a couple game clients I've written. The way I've implemented Dialogs is to have them derive from the base XNAControl class.

XNAControl objects follow the Game Component model and are all derived from DrawableGameComponent. They are added to the Game.Components list as soon as the base class XNAControl constructor is called.

Problem:

Dialogs are popped up in game by instantiating an XNADialog object, unlike MessageBox.Show() which uses a static method. The constructor of XNADialog, in turn, instantiates a couple controls that are 'children' of the parent dialog control. Children are tracked by the dialog, and removed from the Game.Components list automatically when the Dialog is closed.

The problem with the model that I've created is that the child controls are added to the Game's components when they're constructed, so they start updating and drawing and thus show on the screen before the dialog is fully constructed. The case I'm trying to debug is where the labels for a dialog box will appear in the top left, and then move to the center of the screen a split second later once the Dialog is constructed.

What I've tried:

Separate constructor for base class XNAControl that doesn't add the control to the components when it's constructed. Instead, it relies on the child control (in this case dialog) to add itself to the Game.Components collection. This is what I have in place so far and it isn't working, which makes sense, because the labels are being added to the components collection prematurely anyway.
Initialized property of XNAControl. This property is set in the XNAControl.Initialize() method, and the base class XNAControl.Update and XNAControl.Draw return automatically if it is false. However, this isn't working either (also in place) because child controls have to call the base methods of update and draw before after they do their own drawing logic because otherwise some things would be drawn in the wrong order. I also don't want to have to check the Initialized property in every single child class I make because there are a lot of them and I'm looking for something more elegant
Moving the addition of the control to the components collection to the Initialize method. This didn't work because the control's initialize method didn't get called automatically because the control wasn't in the components collection yet.

Question:

What is the best way to keep the child controls from being updated and drawn prior to their parent control's construction? My only other ideas are:

Using a theading sync object, but this seems like overkill/unnecessary (or maybe it's exactly what I need?). I can't think of an elegant way to do it.
Finding a way to cancel any drawing that's been done by the SpriteBatch in the child classes, in XNAControl.Draw. I don't think this is possible though, and I can't find anything searching.


texts:
I use below code to create my particles ( in fact, I don't know any other way.)

spawnedParticleComponents = WorldInfo.MyEmitterPool.SpawnEmitter(ParticleSystem'ParticleName', Location, Rotator );
spawnedParticleComponents.setTranslation(newLocation);
...

And unfortunately, I spawn many particles in game.

When I play my game, after some time, I see Exceeded max active pooled emitters! Warning in console .

To solve the problem, first, I tried spawnedParticleComponents.DeactivateSystem();, But it doesn't help.
Then I try WorldInfo.MyEmitterPool.ClearPoolComponents(false);, But it doesn't either .
:(

How can I destroy many spawned particles and avoid this warning ?


texts: How can I make responsive computer and touch click and drag?

texts:
This code works but it has a little delay on computer controls and higher delay on mobile touch screen controls, so its not responsive as I want it to be.
void OnMouseDown()
{
    offset = transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, transform.position.y, 0.0f));
}

void OnMouseDrag()
{
    Vector3 newPosition = new Vector3(Input.mousePosition.x, transform.position.y, 0.0f);
    transform.position = Camera.main.ScreenToWorldPoint(newPosition) + offset;
    transform.position = new Vector2(Mathf.Clamp(transform.position.x, posXMin, posXMax), transform.position.y);
}


texts: Can Unity support / use textures that are not square?

texts:
I have been told by another highly skilled Unity artist that Unity cannot efficiently handle non square images. Since that doesn't sound right to me, I wanted to get a second or third confirmation to that claim.

Having worked in the game development industry for almost 15 years, I have always understood that best practice was keeping in powers of two, but that if the UV map called for it, a 1024x512 map was acceptable, rather than using a 1024x1024 map with 1024x512 pixels of wasted UV space. Granted, that was best practice on game engines other than Unity.

Can anyone confirm that in Unity's case, it is better (best practice) to have a 1024x1024 image containing UV islands occupying 1024x512 pixels, rather than using a 1024x512 image map to exactly accommodate the UVs?

Which platforms can use non-square images and which ones cannot with the Unity engine? I am particularly interested in whether or not this limitation affects PC builds.


texts:
I'm wondering if this is possible and what obstacles I might face.

I have a game that's browser based, and since I can't send UDP packets from a browser, Can I use a plugin that the browser connects to via a web socket, and have that plugin send the UDP messages?

When the plugin receives a UDP packet, it'll then relay it to the browser via the TCP websocket?

Could this work? And can TCP handle tons of messages from the plugin even though it's connecting to 127.0.0.1? At least 64 players in this game. The UDP packets are usually no more than 40 bytes.


texts:
I'm currently working on a top-down twin-stick shooter for Android. I've got my player moving around and shooting, but I'm looking to add a large Bitmap background which is larger than the device screen.

I'm looking for a way to position the background at 0,0 in 'world' co-ordinates, and have the view able to pan across the background with the player. I've tried using SurfaceHolder.Callbacks, but these do not seem to play nicely with my SurfaceView class. The view currently follows the player while keeping it centred, until it reaches an edge, where it will stop and the player will continue until he hits a wall.

My current thoughts are to store an offset from view co-ordinates to world co-ordinates in the update loop, and draw the bitmap using these offsets in the draw loop. Is there a more efficient way to do this, or a different way to think about it?


texts: Getting and Setting Rotation in XNA around the Center of my Model with XNA

texts:
Alright, so I'm currently debating how I want to do this.  Basically this is what I'm trying to accomplish.

I've created a system to allow me to make my environment a little bit easier.  I'm currently setting up a way to edit my models that I'll be rendering a bit easier.  Currently I'm displaying their properties in a .NET Property Grid like so:

As you can see, I want to be able to rotate my model via 3 separate values.  One represents the rotation around the X axis, one for the Y axis, and one for the Z axis.  I'll be specifying the amounts in degrees (and converting to radians when necessary).  I also want to have it rotate around the center of the object.

Here are the things I have to think about:

How to I unbiased rotate my model (considering I can only rotate one axis at a time via Matrix.CreateRotation[X/Y/Z](angle)
How to make sure it rotates around the center
Extract these three angles back out from a Matrix
How to properly rotate them so that it handles it all intuitively

What do you guys think?


texts: Java and Eclipse setup properly, how do I install JOGL or LWJGL?

texts:
I have my Java environment installed alongside Eclipse, and I was successfully able to create and run a new project (simple System.out.println("Yay I work!");

I have the OpenGL SuperBible, and I primarily want to code 3D things (I'll take my time using the book to learn how to draw shapes in 3D space, etc..)

Can you help me get setup with OpenGL in Java? I dont really need LWJGL, although I WILL make games eventually. I just can't even figure out with all of these terrible (and old) tutorials floating around on the net how to install either JOGL or LWJGL.

If you can give me a hand with that, I'd appreciate it. I'd like to feel I contributed by having this page show the answer to the question, so that other poor souls googling for this same information can benefit.


texts: FPS using mouse to move rather than keys

texts:
Hi I am developing a First person game but would like to use the mouse to move on a click to move as opposed to the keys. I also need to disable Y movement and restrict the x movement to 180. What ever values I enter into the input manager, it seems to be ignoring them as I still have both x and y when I run the game.

I dabbled with the standard unity FPS but is seems very jagged on movement and from what I can see being a new user, their doesn't seem to be a way to restrict y movement. Can someone help with this or suggest a good tutorial on this type of movement. Thanks


texts: Instantiated Different player objects in multiplayer game in unity

texts:
I am using two different objects for player in network multiplayer game. Two different kinds of gameobject will be instantiated by unity network behavior but the problem is there is only single property of playerprefab. How can i set two different objects even i tried to change it on run time but its giving me error.

  Failed to spawn server object,
  assetId=4d293c8e162f3874b982baadd71153d2 netId=1
  UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

  Failed to spawn server object,
  assetId=4d293c8e162f3874b982baadd71153d2 netId=7
  UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()


texts: How to render a retro-like pixel graphics from 3d models?

texts:
I was wondering if there's a possibility to render a retro-pixel-like graphics from 3d model in real time?

I'm talking about the Starfarer-like graphics.
I know it's hand drawn, and it's 2d.
But if I need a 3d objects with the same aesthetics?

I'm currently working with Flash. But I don't need any ready-solutions, I just want to understand the principle from any other platform if there is one.
So if anybody met anything like this I would appreciate your help.
(If it's not possible to do in real time, I could at least pre-render a sequence of sprites. It would be much better than creating hundreds of hand-drawn ones)


texts: A collider defined as intersection of two colliders

texts:
I'm working in unity and I have the following problem :
Suppose you have an object that's very similar to say the intersection of say the corner of a cube and a ball, and you want a nice collider for this object.

First option is to simply use the mesh collider option - but this is apparently not  very efficient, and if for example the sphere is very smooth, there might be a lot of polygons and that could be a problem.

Second, you could just fill the object with various simple colliders.

However, both of the above options seem unnecessarily complicated - it would seem natural to me to somehow work with both colliders - the sphere collider and the cube collider. To determine if the object is touching something, the requirement is that both the cube and sphere collider are touching something, not just one of them.

I don't know how the actual collision checks work, but I would expect that say in the second option I wrote above (placing a few small colliders inside the object), a collision check sees if any of the colliders is touching a collider of some other object - so there is an option for "union" type of collision check (see if any of the colliders are touching something). Similarly, I would expect there would be an option of checking whether both the colliders are touching something, but I'm not aware of it.

Either way, I would appreciate ideas on how to implement a good collider for this problem, and whether there's a way to implement it by the way I described, using the "intersection" of two colliders.


texts: Augmented reality on Mobile platform - iOS

texts:
Is there a way that we can control the iOS device camera to an extent what colors it sees, what shapes it sees ? etc

I'm speaking about the ability to read information before the image is captured.

Consider my question as: Possibility of making an augmented reality game on iOS phones.

I dont find relevant help for my query in internet/iOS developer site. Hence posting here.


texts:
I'm making an isometric map for a game, I can draw it, but I don't know how to implement a sort of 3d collision detection without Threejs or other 3d library.

It is possible? Maybe make the block an Object can help? I have searched a lot on the web, but I found only libraries. Thank you!

This is my JavaScript code:

var canvas = document.getElementById('canvas'),
 ctx = canvas.getContext('2d'),
 width = canvas.width = window.innerWidth,
 height = canvas.height = window.innerHeight,
 stop = false;

var tw, th;
var player;

setup();
draw();

function setup(){
  ctx.translate(width/2,50);

  tw = 60; //tile width
  th = 30; // tile height
  player = new Player(2,3,2);

};

function draw(){

  ctx.clearRect(-width/2,-50,width*1.5,height+50);

    for(var i = 0; i < 5; i++){
      for(var j = 0; j < 5; j++){
        drawBlock(i,j,1,tw,th);
      }
    }

    if(!stop){
     requestAnimationFrame(draw);
    }
}

function drawBlock(x,y,z,w,h){

 var top = "#eeeeee",
     right = '#cccccc',
     left = '#999999';

 ctx.save();
 ctx.translate((x-y)*w/2,(x+y)*h/2);

 ctx.beginPath();
 ctx.moveTo(0,-z*h);
 ctx.lineTo(w/2,h/2-z*h);
 ctx.lineTo(0,h-z*h);
 ctx.lineTo(-w/2,h/2-z*h);
 ctx.closePath();
 ctx.fillStyle = "black";
 ctx.stroke();
 ctx.fillStyle = top;
 ctx.fill();

 ctx.beginPath();
 ctx.moveTo(-w/2,h/2-z*h);
 ctx.lineTo(0,h-z*h);
 ctx.lineTo(0,h);
 ctx.lineTo(0,h);
 ctx.lineTo(-w/2,h/2);
 ctx.closePath();
 ctx.fillStyle = "black";
 ctx.stroke();
 ctx.fillStyle = left;
 ctx.fill();

 ctx.beginPath();
 ctx.moveTo(w/2,h/2-z*h);
 ctx.lineTo(0,h-z*h);
 ctx.lineTo(0,h);
 ctx.lineTo(0,h);
 ctx.lineTo(w/2,h/2);
 ctx.closePath();
 ctx.fillStyle = "black";
 ctx.stroke();
 ctx.fillStyle = right;
 ctx.fill();

 ctx.restore();

}

function drawTile(x,y,stroke,col){

 ctx.save();
 ctx.translate((x-y)*tw/2,(x+y)*th/2);

 ctx.beginPath();
 ctx.moveTo(0,0);
 ctx.lineTo(tw/2,th/2);
 ctx.lineTo(0,th);
 ctx.lineTo(-tw/2,th/2);
 ctx.closePath();
 if(stroke){
  ctx.stroke();
 }else{
  ctx.fillStyle = col;
  ctx.fill();
 }

 ctx.restore();

}

function Player(x,y,z){
  this.x = x;
  this.y = y;
  this.z = z;
  this.w = 10; //width
  this.h = 10; //height
}
canvas{
  width:100%;
  height:100%;
}
<canvas id="canvas"></canvas>


texts: How do I rotate a sprite around a pivot point using SDL_gfx's rotozoomSurface?

texts:
Using SDL_gfx's rotozoomSurface function to rotate a 38x58 sprite....naturally when it rotates it creates a new surface with a new size, and the rotation isn't going around the center point.  I am actually having issues trying to figure out how to make it seem like its spinning around an axis...

Here is the image that I am using:

And here is the code that I have thus far:

  #define ANGLE_STEPS 32
  #define ANGLE_STEP  (360 / ANGLE_STEPS)
  ...
  int angle = 0;
  SDL_Rect cpos;
  cpos.x = cpos.y = 100;
  ...
  // create chopper angled surfaces
  for (int i = 0; i < ANGLE_STEPS; i++)
  {
    choppers[i] = rotozoomSurface(chopper, i * ANGLE_STEP, 1, 0);
  }
  ...

  // blit the currently requested angle
  SDL_BlitSurface(choppers[angle], NULL, screen, &cpos);
  ...

  // handle rotating the chopper
  if (keystate[keys[LEFTKEY]])
  {
    angle = (angle + 1) & (ANGLE_STEPS - 1);
    cpos.x = ?
    cpos.y = ?
  }
  if (keystate[keys[RIGHTKEY]])
  {
    angle = (angle - 1) & (ANGLE_STEPS - 1);
    cpos.x = ?
    cpos.y = ?
  }


texts: Adaptive Characters: AI Solution Needs a Problem

texts:
Have sophisticated adaptive programming, will travel - so to speak. I'm part of a group that developed sophisticated learning / adaptive software for robotics. The system "thinks" via its simulator, building and adapting code on its own; and then carries out the best solution. The software can also adapt to new situations, etc.
http://mensnewsdaily.com/2007/05/16/robobusiness-robots-with-imagination/

It's easy to imagine using it with automated game characters that will adapt to the players moves and style - the easiest example would be fighting. The more the simulated fighter fights with the human player, the more it learns to counter that players fighting skills. But there should be more.

Anyone have any ideas as to how adaptive characters might be interesting in games?


texts: Maya 3d Model. 2+ Materials on a face? Snooker Table felt with lines overlay

texts:
I've made a snooker table in Maya for use in a game in Unity.
The felt texture on the table is a tiled texture, I used Blinn, and 'place2dTexture' node to do the tiling.
It all looked great. Except I had hoped to 'overlay' another texture on top of the felt which is the straight line and semi-circle drawn across the table.
I couldn't use the same texture with UV mapping because the felt texture is tiled, and of course the lines texture is not (ie. It is intended to fill the whole plane on 1 to 1).
Is there a solution to this? Basically I need to know a way to overlay a non-tiled, partly transparent texture, on top of a tiled one.
Thanks for any help.


texts: Direct3D9 depth write without depth test

texts:
In OpenGL and Direct3D11 depth write is disabled if depth test is disabled. To enable depth write with out depth test in gl you must enable depth test with depth func always.

OpenGL

  Even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. In order to unconditionally write to the depth buffer, the depth test should be enabled and set to GL_ALWAYS (see glDepthFunc).

Direct3D11

  DepthEnable and StencilEnable enable (and disable) depth and stencil testing. Set DepthEnable to FALSE to disable depth testing and prevent writing to the depth buffer. Set StencilEnable to FALSE to disable stencil testing and prevent writing to the stencil buffer (when DepthEnable is FALSE and StencilEnable is TRUE, the depth test always passes in the stencil operation).

I can't find any documentation on this behavior for d3d9.

In Direct3D9 if D3DRS_ZENABLE is set to D3DZB_FALSE and D3DRS_ZWRITEENABLE is set to TRUE is the depth buffer written to?


texts: How do I avoid lag when dynamically loading a map chunk?

texts:
I have a procedural 2d game which extends in all directions, on the surface similar to Terraria. When a player moves their camera close to the edge of the currently loaded terrain, I trigger an expand event, which loads new chunks of terrain. Each chunk is an N×N section of tiles. When I do this I get a stutter of about 1 second due to the cost of procedurally generating the new tile set.

How can I avoid that delay?

Currently, all new chunks are loaded in the same iteration of the update loop (bad I know). My current idea is to create a queue to store the chunks and only render 1 chunk per game update.


texts:
For MMORPG, there is a tick function to update every object's state in a map. The function was triggered by a timer in fixed interval. So each map's update can be dispatch to different thread. At other side, server handle player incoming package have its own threads also: I/O threads. Generally, the handler of the corresponding incoming package run in I/O threads. So there is a problem: thread synchronization. I have consider two methods:

Synchronize with mutex. I/O thread lock a mutex before execute handler function and map thread lock same mutex before it execute map's update.
Execute all handler functions in map's thread, I/O thread only queue the incoming handler and let map thread to pop the queue then call handler function.

These two have a disadvantage: delay. For method 1, if the map's tick function is running, then all clients' request need to waiting the lock release. For method 2, if map's tick function is running, all clients' request need to waiting for next tick to be handle.

Of course, there is another method: add lock to functions that use data which will be accessed both in I/O thread & map thread. But this is hard to maintain and easy to goes incorrect. It needs carefully check all variables whether or not accessed by both two kinds thread.

My problem is: is there better way to do this? Or from practical view, the delay can be accepted because nothing will happen between 2 tick (the world is driven by continuous tick, all object will paused in 2 tick's interval) Generally, the interval is about 50ms to 100ms

Notice that I said map is logic concept means no interactions can happen between two map except transport. I/O thread means thread in 3rd part network lib which used to handle client request.


texts: AddForce doesn't work anymore when Acceleration is added

texts:
Everything worked fine until I added acceleration on the x axis..now when I try to jump it just lifts up very little from the ground in a weird way and then it slowly sinks down like having 0 gravity. Here is the code I'm using:

public class PlayerMovement : MonoBehaviour {

    public float baseSpeed = 10f;
    public float maxSpeed = 10f;
    public float timeFromZeroToMax = 10f;
    public float jumpSpeed = 10f;
    public Collider coll;

    float accelRatePerSecond;
    float forwardVelocity;
    Rigidbody rb;

    void Awake () {
        rb = GetComponent<Rigidbody>();
        coll = GetComponent<Collider>();

        accelRatePerSecond = maxSpeed / timeFromZeroToMax;
        forwardVelocity = 0f;
    }

    void FixedUpdate() {

        transform.Translate(transform.right * baseSpeed * Time.deltaTime);
        forwardVelocity += accelRatePerSecond * Time.deltaTime;
        forwardVelocity = Mathf.Min(forwardVelocity, maxSpeed);

        if (isGrounded() && Input.GetKeyDown("w"))
        {
            rb.AddForce(transform.up * jumpSpeed * Time.deltaTime, ForceMode.Impulse);
        }

    }
    void LateUpdate()
    {
        rb.velocity = transform.right * forwardVelocity;
    }
    bool isGrounded()
    {
        return Physics.Raycast(transform.position, Vector3.down, coll.bounds.extents.y + 0.1f);
    }
}


texts:
I'm trying to play a video in a monogame project. I've done this in XNA in the past by including the Framework.Video directory and it's very simple. This cannot be done in monogame as Visual Studio 2012 wont accept the XNA directories.

I've not been able to find any other way explained anywhere if you can actually put video in monogame yer and if you can how it's done.

Any ideas?


texts:
I'm currently in the process of making a top-down shooter for my programming class, and one idea I had, but don't exactly know how to implement is image rotation in order to spin the object continuously. What I have are spaceships, and right now all they do is face one static direction. All I want is to have them non-stop spinning at a rate that people can see (not so fast that it looks like a blur). I've seen some code about rotating by a certain degree, etc; but no constant rotations. I'm not too sure how to go about this, but any help would be appreciated greatly.

Also, I'm using C# and Visual Studio 2010.


texts: Implement Hearthstone disenchant extra cards particles

texts:
How would you implement the hearthstone flying particles? like you can see here
These are not just simple particles flying from a to b... I think that they are flying in some random spline, and stretched...

Any information, even to something similar that you can point me to would help!
Thanks


texts: Do iOS users use Facebook and Twitter buttons within games?

texts:
Does anyone have any insight or experience into the successfullness of placing Facebook or Twitter "share" buttons within an iOS game?  For example, when a user gets a high score, presenting them with the option to share their score via Facebook or Twitter.

My reservations/bias against including Facebook or Twitter buttons in my game are:

Distrust of buttons that auto-post without giving one the chance to format the text yourself
I don't use themself because I tend to manually create tweets or Facebook wall posts on my own

On the other hand, the potential benefits of such buttons can obviously be profound.  The question is simply: do iOS users actually use such buttons?


texts: Google admob ad shown after clicking multiple times

texts:
I'm using google admob to show rewarded video ads in my game. Once the game is over, the play video button is enabled. If the user clicks on that, a panel opens asking "would you like to revive the player by watching an ad". There are two options, one is to hit "ok" and the other to cancel "x". The issue is that the I have to click on "ok" multiple times for the ad to show. Sometimes the ad doesn't show at all no matter how many times I click on "ok" .Here is the code I have in adscript:
public class AdScript : MonoBehaviour
{

string App_ID = "ca-app-pub-123454545~12345678";

string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";

private RewardedAd rewardedAd;

void Start()
{
    MobileAds.Initialize(App_ID);
}

public void RequestRewardBasedVideo()
{

    this.rewardedAd = new RewardedAd(Video_Ad_Id);
    AdRequest request = new AdRequest.Builder().Build();

    this.rewardedAd.LoadAd(request);
    this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;

    this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;

    this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;

    this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;

    this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;

    this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
}

public void ShowVideoRewardAd()
{
    if (this.rewardedAd.IsLoaded())
    {
        this.rewardedAd.Show();
    }
}

public void HandleRewardedAdLoaded(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleRewardedAdLoaded event received");
}

public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args)
{
    MonoBehaviour.print(
        "HandleRewardedAdFailedToLoad event received with message: "
                         + args.Message);
}

public void HandleRewardedAdOpening(object sender, EventArgs args)
{
    MonoBehaviour.print("HandleRewardedAdOpening event received");
}

public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
{
    MonoBehaviour.print(
        "HandleRewardedAdFailedToShow event received with message: "
                         + args.Message);
}

public void HandleRewardedAdClosed(object sender, EventArgs args)
{
    this.RequestRewardBasedVideo();
}

public void HandleUserEarnedReward(object sender, Reward args)
 {
    GameManager.instance.ReceiveReward();
 }
}

The function RequestRewardBasedVideo() is added to the play video button and the ShowVideoRewardAd() is added to the "ok" button. The test ads show properly but the issue is that I have to hit the ok button multiple times for the ad to display. I'm not sure why this is happening. Can someone please help?


texts: How do I import real world models into a game engine?

texts: What are the hardware and software tools required to import physical worlds into a game engine? Can I use a HD camera to do that? What do the popular game engines support?


texts: How to calculate the vector of an interception?

texts:
Given are a twodimensional space, and 1 friendly spaceship standing still, one foe is moving NOT directly to the friendly ship with known actual position, speed and direction.

The friendly ship wants to get itself into firing range to battle the foe.

Actually I am setting just a direct vector to the actual position moving ship, and recalculate it every frame, resulting in some kind of "round" flightpath.

What I want is to set a direct and straight path to the position that the foe will (presumably) will have when firing distance will be reached, assuming that foe will not change course until then.

As a first and "simple" implementation it would be enough if we assume the friend can speed up from 0 to max in no time.

Preffered implemantation would be one that considers the acceleration capabilities of the friend, and knows when interception is impossible because of the speed. It should work for every starting speed, not only from stand still. A plus would be if it even considers braking (battling at lightspeed is very energy inefficient in the given universe)


texts:
I was looking for a pixelation shader for my postprocessing and came across this shader snippet - Works pretty well! - Not a whole lot of explanations on how it works except for "Pixelation is process when pixel at [x, y] is duplicated into [x + dx, y + dy] rectangle"

I re-wrote/formatted the shader a bit:

out vec4 FinalColor;
in vec2 FragUV;
uniform sampler2D Texture;

void main()
{
        float Pixels = 512.0;
        float dx = 15.0 * (1.0 / Pixels);
        float dy = 10.0 * (1.0 / Pixels);
        vec2 Coord = vec2(dx * floor(FragUV.x / dx),
                          dy * floor(FragUV.y / dy));
        FinalColor = texture(Texture, Coord);
}

My understanding: Messing with the 'Pixels' I found that the higher this number the more pixels there on the screen/the smaller the size pixels get thus a less pixelated effect. Then he's calculating some x and y offset values based on that number and using those offsets to get new texture coordinates to sample from.

My question: I have no idea how that's actually happening. I mean how does all that achieve "duplicating a pixel at [x, y] is into [x + dx, y + dy] rectangle"? What does 15 and 10 represent? (how much to offset on x and y?) - What happens when we actually multiply dx/dy with the result of the floor function and divide the texture coordinate by them? and why 'floor' in particular?

Any help or explanation is appreciated, thanks!


texts: intersection of primitive in a unit wrapping 3D space

texts:
is there people good enough for a math problem (for a shader)?
I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping space, no raymarching, at least axis aligned.

The goal is to write a shader. The benefit, is that, since it's analytic, I can do trick by passing parameters with the texture per pixel.

I already do this by abusing simpler variants of of interior design, by cranking the space between side low, and get dense (simple) foliage and grass for free, or brick walls, or any greebles. Except I'm confined to simple convex shapes with interior style shader, with this I could have more interesting parallax to abuse artistically. I use the flow of the polygon surface to create interesting shapes, and UV texture to break pattern artistically. Work wonder for low specs machine!

I figure out how to do it with a single point at the boundaries of the space, using the planet alignment problem (akin to the two clock hand overlap problem). But I failed to generalized it.

This problem is similar to this math problem
https://amininima.wordpress.com/2013/05/27/the-laser-gun/

But without the reflection.

Other potential benefits is that it have a period we can find mathematically, we could probably infer an analytical "overdraw", by "discarding depth" have a "traversed thickness", if we generalized the, such as we can also shift the position of the primitive at each "jump", we could probably find a consistent "integral 3D noise", which would made cloud noise in convex volume much cheaper than marching.

  Optionally "the graal" would be at least 1 period coil repeated on axis aligned.
  But we can't intersect cosine "cheaply", I tried using x²
  approximations but my math melted. A unit coil being an unwrap unit
  cylinder diagonal, was the next step explored, ie to intersect axis
  aligned cylinder then find on its surface the diagonal:
  the idea above is, taking the perpendicular going through the cylinder center, we observe that the tracing "regularly" step through it, using that stepping and the slope of the ray, we can infer point on the wrapping surface of the cylinder, the entire idea is to find the step pattern so we can intersect the diagonal within a certain distance.

EDIT: While talking below in the comment, I realized that I probably could shift the 1D wrapping space to the 2D projection of the ray direction, then find the period of the primitive's "axis" projected on that line, and since I already found the case for 1D, use that to infer the remaining intersection. Just an idea not developed yet. Should make a drawing to show what I mean, it's not clear yet in words.


texts: How to implement 'Fog of War' in SpriteKit or Cocos2D?

texts:
Take a look at the image below from the game Warcraft 2. There's a darkened area (like a fog) that represents the limits of the 'field of view' -- to the effect that you would not see any enemy characters in the fog.

How would you implement this 'fog' in iOS (SpriteKit, Cocos2d, etc)? Mostly interested in hearing high-level strategies on implementing the fog itself -- within the node-based hierarchy of something like SpriteKit or Cocos2d.

And bonus: what do people call this 'fog' in the game industry?

[Update] 'Fog of War' (thanks @Jon)


texts: Generating a particle effect on top of a GUIElement (Unity)

texts:
I am working in Unity on a 2D project which is using C#.

I have a number of guitextures which are hearts in order to create a sort of life meter. I would like when the player loses a heart for the heart to change into a skull in a puff of smoke. I currently have the hearts correctly turning into skulls, and a puff of smoke is generated, however the smoke is created in the wrong location.

The smoke is currently generated by:

GameObject smokeObj = (GameObject)Instantiate (smoke, transform.TransformPoint(transform.position), Quaternion.identity);

I have also tried:

GameObject smokeObj = (GameObject)Instantiate (smoke, transform.position, Quaternion.identity);

I know that the reason that the smoke is created in to wrong location is due to GUIElements using a different coordinate system than other gameObjects.

How can I create the smoke in the correct location?

This is a 2D project and I am currently using Unity 4.5of6, with windows 8.1.

Thank you for your assistance, if you have any questions please do not hesitate to ask.

EDIT:
I have also tried the following, yet it also works incorrectly:

Vector3 worldPos = cam.ViewportToWorldPoint(transform.localPosition + Vector3.forward);
        worldPos.z=0;
        GameObject smokeObj = (GameObject)Instantiate (smoke, worldPos, Quaternion.identity);
        Debug.Log(worldPos);
                //smokeObj.layer = 5;
                smokeObj.transform.parent = this.transform;


texts:
I am creating a JavaScript game that is currently implemented as follows:

Run a game loop
Check for arrow keys pressed
When arrow is pressed, calculate the new player coordinates
if new player coordinates result in a collision, do not move the player, but instead append a status message to the onscreen status box

My issue is that if I am holding down the arrow key and collide with an object, that onscreen status box gets hundreds of messages appended to it.

I originally thought that a way to get around this would be to check the last line in the status box and if it is the same as the new line then not to append the new line. However, this will cause a problem if the user walks away and comes back to the same object again, in this case the user SHOULD see a second message appended to the box.

What is a proper way to deal with this situation?


texts: Higher Performance With Spritesheets Than With Rotating Using C# and XNA 4.0?

texts:
I would like to know what the performance difference is between

using multiple sprites in one file (sprite sheets) to draw a game-character being able to face in 4 directions and
using one sprite per file but rotating that character to my needs.

I am aware that the sprite sheet method restricts the character to only be able to look into predefined directions, whereas the rotation method would give the character the freedom of "looking everywhere".

Here's an example of what I am doing:

Single Sprite Method

Assuming I have a 64x64 texture that points north.

So I do the following if I wanted it to point east:

spriteBatch.Draw(
    _sampleTexture,
    new Rectangle(200, 100, 64, 64),
    null,
    Color.White,
    (float)(Math.PI / 2),
    Vector2.Zero,
    SpriteEffects.None,
    0);

Multiple Sprite Method

Now I got a sprite sheet (128x128) where the top-left 64x64 section contains a sprite pointing north, top-right 64x64 section points east, and so forth.

And to make it point east, i do the following:

spriteBatch.Draw(
    _sampleSpritesheet,
    new Rectangle(400, 100, 64, 64),
    new Rectangle(64, 0, 64, 64),
    Color.White);

So which of these methods is using less CPU-time and what are the pro's and con's?

Is .NET/XNA optimizing this in any way (e.g. it notices that the same call was done last frame and then just uses an already rendered/rotated image thats still in memory)?


texts: How to create a seamless 5D noise function?

texts:
I would like to create a seamless 3D Texture, I have read that it's doable with a 5D noise function but I can't find any implementation and the math is over my head here.

How can I create a 5D noise function to create a seamless 3D texture?


texts: Painting terrain with a selection circle

texts:
I don't mean putting a circle under a unit like done in an RTS, that's fairly simply done with a scenegraph(-like structure). What I'm referring to is selection circles for things like Area of Effects that are painted on the terrain.

It seems relatively simple until I think about it.

Here are some images for reference:

http://i.stack.imgur.com/iXWXB.jpg
http://im.tech2.in.com/images/2009/jan/img_116282_initialthreat_640x360.jpg

The first image gets the idea across, but not the full scope. Basically, the floor is painted with a decal detailing the region that will be affected by the spell.

The second image gets it across much better, it's not just a flat painted circle, it wraps along the mesh.

At first I figured to use some sort of object selection, and then in the vertex shader draw the texture on the correct vertices based on... some criteria that I'm still working out. Most likely based on distance and angle from the intersection point. The difficulty seems to come in that the methods wrap onto objects that seem to be completely different meshes.

I can't find an image that shows it (and don't play WoW anymore so I can't take a screenshot), but say you have a terrain mesh and a house on top of it and I select a point very close to the house's wall. Instead of continuing on the terrain mesh, the selection circle will go as far along the terrain mesh as it can, and then wrap up onto the wall of the house. It also ignores certain objects (players, etc), but that's pretty easy to ignore with correct collision tags/callbacks.

It's not so much that I can't think of a way to do this, but all the ways I can think of would probably lag your game out or turn your processor into slag. Somehow I have to:

Draw a texture
With no breaks
Wrapping on multiple objects according to the terrain
Centered at a given point
Completely dynamically (so no pre-baking it into a bunch of dummy textures)
Quickly enough to be computed every frame

Is there a standard method for this? Am I just overthinking it?

My best guess is rather than do one ray cast and selecting that point as the "center" I do a bunch of casts and in each case select the nearest vertex and bind the appropriate UV coord to that vertex, but it seems messy and potentially performance heavy to select that many vertices that way at the CPU frame-by-frame level. Especially since ray casts in general are expensive, even with a good physics engine.

It also doesn't seem particularly portable to anything other than a selection circle. A similar case would be like drawing the movement arrow over the terrain in Total War games, a thick arrow is drawn between the unit and its destination (see here: http://webguyunlimited.com/pixelperfectgaming/wp-content/gallery/total_war_shogun_2_rise_of_the_samurai/total_war_rots_screenshot_014.jpg ), this would seem to be a very similar technique to the AOE selection circle, but the ray cast method I mentioned wouldn't really work for it. There are, of course, numerous other examples too (such as trajectory markers).


texts: Drawing a textured triangle with CPU instead of GPU

texts:
I understand the benefits of GPU rendering and such, but for a certain limited application I need to render textured triangles purely using CPU.

I've built a 3D engine capable of object handling, transform, projection, culling and the likes ... now all I need is a little code snippet that draws a single textured triangle onto a bitmap... any language accepted!

Inputs: Texture bitmap, Triangle U/V/W coords, Triangle X/Y screen coords
Output: The textured triangle drawn at the given screen coords

I've currently been using a platform function to draw triangles to screen, but I'm looking to handle it myself to speeden up the process.


texts: How can I send matrix data to shaders without the Effects11 framework?

texts:
I'm making a Direct3D engine but I'm stuck with this one little problem.

I want to not use effect files but instead use shader files. What can I use to send matrix variables to shaders if I don't use ID3D11XEffectMatrixVariable?


texts: Why do multiplayer games/chat services ever need to be able to open all NAT ports?

texts:
I understand that games need to be able to open NAT ports in order to receive incoming connections.

What I do not understand is why there is an issue between "limited" and "open" NAT. The only reason I can see that a game would ever need to have the flexibility to open any port is if it is intending to accept incoming connections on ports that aren't specified in advance as part of the protocol. (If there was a restricted set specified in advance, forwarding these and no others should satisfy all of the game's demands for NAT forwarding, meaning that "open" would not need to be a thing.)

This seems to imply there's some port negotiation going on as part of the protocol (otherwise how does the connector know that this port, not specified in advance, is available?) but if a connection is already established to conduct the negotiation, why move to a different port? And even then, why can't negotiation be limited to a subrange of ports rather than the entire range?


texts: Performance cost of creating local variables just for 'readability'?

texts:
I am learning C++ and Unreal Engine. I'm wondering if creating local variables inside functions purely to help me read the function later will cost my game/code in performance (assuming if I carry on this practise over hundreds/thousands of functions/variables).

Eg:

void APostie::MoveForward(float Value)
{
FVector Delta = GetActorForwardVector() * BaseWalkSpeed * Value * GetWorld()->GetDeltaSeconds();
FRotator NewRotation = GetActorRotation();
FHitResult Hit;
GetCharacterMovement()->SafeMoveUpdatedComponent(Delta, NewRotation, true, Hit);
}

Here the 'NewRotation' variable is completely useless. But I am intending to copy-paste this function and use it in similar input functions that will require the NewRotation to have a calculation on it.

So is it much better peformance-wise to have the function like this instead (again, imagine there are several hundred similar situations in a code solution)

void APostie::MoveForward(float Value)
{
FVector Delta = GetActorForwardVector() * BaseWalkSpeed * Value * GetWorld()->GetDeltaSeconds();
FHitResult Hit;
GetCharacterMovement()->SafeMoveUpdatedComponent(Delta, GetActorRotation(), true, Hit);
}

As you see in the second version the Rotation is set directly. Does this make any difference to game performance (including Networked games) ? Thanks


texts: Removing drawn Allegro texts and primitives

texts:
I'm working on a game with Allegro 5 that has a loop. I'd like to make the program write onto the screen, how much time the loop has ended. These are the rounds of a turn-based game, obviously. I use the al_draw_textf function for it, which works perfectly, but I put it into the loop. Its consequence is obviously that the number is written on the same place all the time.

To prevent it, I should delete it at the beginning of every loop. Sadly, I couldn't find any functions in Allegro Manual that does it. How can I do that then?


texts:
I am having trouble spawning some obstacles from some prefabs. The aim is to make and endless runner (like normal) with obstacles to go through that spawn as the sprite goes up. But my prefabs don't spawn at the top?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RandomSpawn : MonoBehaviour
{
    public GameObject B1, B2;
    public float spawnrate = 2f;
    float nextSpawn = 0f;
    int whatToSpawn;

    void Update()
    {
        if (Time.time > nextSpawn)
        {
            whatToSpawn = Random.Range(1, 3);
            Debug.Log (whatToSpawn);

            switch (whatToSpawn)
            {
                case 1:
                    Instantiate(B1, transform.position, Quaternion.identity);
                    break;
                case 2:
                    Instantiate(B2, transform.position, Quaternion.identity);
                    break;
            }

            nextSpawn = Time.time + spawnrate;
        }
    }
}


texts: Given a point on the surface of an OBB, return normal of the face

texts:
So I have this class OBB which implements a test function that determines whether a ray hits it. If it does, a passed in struct is assigned a bunch of variables:

struct HitData
{
    float   t;
    Color   color;
    Shape* lastShape = nullptr;
    Vec lastNormal;
}

The last member, Vec lastNormal; is supposed to get its value from the class'

normal(Vec& point) function.

Here's where I'm drawing a complete blank. I.e. I cant seem to find any obvious (or non-obvious) solutions to how to determine the normal.
Essentially what I want to do is identify which of the 6 planes the point lies on. In theory I could brute-force it and just do an intersection test against all the planes but that just seems unnecessarily expensive.
The OBB is defined by a center, three basis vectors and their half-lengths.

Any idea how I could approach this problem?


texts: Synchronization between server's value and the one showed in a stat bar (health, stamina, mana...)

texts:
I am trying to implement a stamina system for my mmo. In few words, I computed everything on the server that then notifies the client. On the client I have a stamina bar that shows the stamina amount. My problem is that the values on the server and the one on the client often go out of synch because of network delay and that causes odd behaviours on the bar.

EDIT 2:

There are things that can affect the regeneration/depletion of a stat. My architecture is server authoritative and the server is in charge of handling the flat changes and the changes in the delta amount per second, that's a constraint.

END EDIT 2.

The communication scheme is between Client (C) and server (S) is the following:

C: me want use stamina

S: ok your stamina is X descreasing at Y/s

C: set stamina to X and animate the bar accordingly to Y/s

every 1 sec after this initial handshake

S: this is your stamina X_i and it is decreasing at Y_i/s

C: use information to animate the stamina bar coherently yet in a way that resembles linearity

as soon as S knows stamina is 0

S: your stamina is 0

C: set stamina bar to 0

Due to loss of synch, the value 0 may appear when the real value is not really 0. The client holds a float amount that is decreased/increased and ceiled to int at every frame to be displayed.

Options I have already tried:

-Whenever the server updates you, force its value: causes jumpy behaviours and doesn't achieve fake linearity

-Whenever the server updates you, calculate the client regen/loss factor as (server amount + delta amount per second) - client amount. Causes the most overshots (client value going to zero when it should not be 0).

-Whenever the server updates you and you find a delta between the server value and the client value, run a coroutine that adds/subtracts over two or three frames that delta to the client value. Still too jumpy and sometimes the error is so big it makes the bar make huge leaps.

Language c#, network library photon, engine unity.

EDIT 1:

My partial solution has been:

The server sends you an update including a duration and a target value predicted for when that duration has elapsed. The client at each update starts a tweener (DOTween library) from it's current value to the target value over that duration. I had the issue that sometimes the client would display 0 when it wasn't the case on the server due to network delay that didn't stop the client in time, and if you reach 0 in my case I have to perform a cooldown wait that wasn't happening being the command to start the cooldown issued by the server. So what I've done has been to make the server accept the 0 from client when it was the case. It seems to work but on changes on the delta value per second, sometimes it might slow down or get quicker in a way that it is noticeable, sometimes.

END EDIT 1.

EDIT 3:

Additional tweak that makes it look a little better.

When the event that starts/stops consuming the stat occurs in the client, I stop the stat bar and wait for server update.

END EDIT 3.


texts: Learning math from the basic to become a game programmer

texts:
Hi i want to become a game developer. Im currently doing some web programming. I want to learn
game programming. Im not good in math thats why i decided to learn from basic math to be sure i will not missed
some important concepts. Do you have some advice if my way of learning is ok. thanks.


texts:
Some definitions:

An oriented bounding box (OBB) is a rectangular block which can be represented in many ways, as a collection of eight vertices, a collection of six planes or others, for this particular case let's just consider these 2.
The camera frustrum is a convex object formed by 6 planes, resulting from converting the unit cube [(-1,-1,-1),(1,1,1)] to world space.

After a lot of researching I've seen you can use the SAT theorem to check collision between convex objects so I assume this could be a choice to check whether my objects will intersect with the camera frustrum.

Right now I've got the OBB of my meshes stored as 8 vertices in world space and my camera frustrum stored either as 8 vertices or 6 planes (also in world space).

So my question, is it SAT suitable to solve this particular problem? If it's so, how would you implement it or where can i find a decently fast implementation of it?


texts: Is using SharpDX or SlimDX easier than using DirectX directly from C++?

texts:
I decided to learn to program in DirectX yesterday, and, not being a huge C++ fanatic, went looking for a .Net wrapper. After reading about SlimDX and SharpDX, I decided I liked what the SharpDX people were doing and began trying to use it. Although they have a huge number of samples that are really nice,  I had trouble finding any tutorials specifically for it. I ended up seeing a huge number of C++ tutorials. Besides the really long and less than aesthetically pleasing function names, it really didn't seem any more complicated than using the managed wrappers.

So my options (and what I think about them) are:

SlimDX/SharpDX are in a language I am familiar with, but nearly as complicated as the C++
DirectX is C++, something I am not too familiar with. I would really need to learn proper memory management.
Focus on really learning C++ well before diving into game programming with straight Direct3D. This would allow me to learn proper memory management and get comfortable with C++.

My original thinking was that if using Direct3D was just as easy as a managed equivalent, there would be no point starting with the managed equivalent. On the other hand, if the managed equivalent is much easier, it would allow me to focus on the ins and outs of developing a game rather than constantly worrying about the language and getting even small things done.

So, will using one of these managed wrappers be easier than using the native Direct3D API itself?


texts: How can I find the object closest to a given 2D point?

texts:
I have an array of objects. Their position is a Vector2. I want to select the closest object, given an X and Y coordinate that represents an user touch on screen.

How can I do this?


texts:
I want to make a game (turn-based RPG) that looks very similar to Bastion.

Here is what I need to implement:

-> The overworld is 2d, with an isometric view.  The graphics would in no way be rendered in 3D, but rather drawn in 2d.

-> The characters would be rendered in 3d, moving about in the 2d isometric world. (Even if the characters are in 3D in a 2D environment, its not much of an issue since a 3D character may actually be rasterized in a series of 2D images, in other words, this isn't much of a problem I feel)

I have looked at several game engines, but I find it very difficult to know which would be best to implement this sort of look and feel.  Which game engine do you guys feel could be best for me so that I would have the least amount of coding to do for purely the isometric view aspect?


texts:
I'm trying to make an object rotate up on the Y axis 90 degrees, then stop. I've got the rotating up bit working fine, it's getting it to stop once it hits 90.

Some of the things I've tried include the following:

float i = rotateSpeed * Time.deltaTime;
while ( x != 90 )
        {
        transform.Rotate( i, 0, 0);
        }

        int x = 0;
x++;

        if( x == 90 )
        {
            transform.Rotate( 0, 0, 0 );
        }

For some reason I can't get this simple thing to work. What am I missing / not doing?


texts: OpenGL - How to draw each nth triangle using glVertexAttribPointer

texts:
I have a vertex buffer. There are situations when I don't want to render the whole mesh, but let's say each nth triangle of the mesh.
I am using VAOs and VBOs.

My data in the buffer is like this:

first triangle indx        seciond triangle indx
0 1 2   3 4 5   6 7 8    | 9 10 11   12 13 14   15 16 17 ...

What I want to do is - render first triangle, then skip second, then render 3d and so on.
Can it be done with adjusting glVertexAttribPointer() or are there some other gl methods that can manipulate the data like that, or I have to create a new buffer with skipped triangles ?


texts:
Had been any efforts made
to stream real-time sound from the microphone (user's voice)
into the game currently played?

This way you could hear echo of your own voice
when you walked into enclosed space,
strong or faint voices in a multiplayer game depending
on distances between players, ...


texts: In Unity, rotating character spine keep going back to original rotation

texts:
this is the code for rotating spine in my character model:

Transform spine;
float horzMovement;

void Awake() {
    spine = transform.Find("Character/Healthmale/Root/pelvis/spine_01");
}

void Update() {
    horzMovement = Input.GetAxis("Mouse Y");
}

void LateUpdate() {
    spine.localRotation = Quaternion.Euler(
        spine.localEulerAngles.x + horzMovement,
        spine.localEulerAngles.y,
        spine.localEulerAngles.z
    );

    print(horzMovement + " / " + spine.localRotation.eulerAngles.x + "    " + Time.time);
}

Code is quite simple, I'm just rotating "X" axis from y mouse movement. The problem is when running this code, it seems work but it keeps rotating back to the original rotation.

This is the log that I printed into the console. Note that spine's original x rotation is about 27.62928.

0 / 27.69298    4.510662
0 / 27.69298    4.527147
-0.1 / 16.33139    4.543715    // minus movement detected
-0.1 / 16.3314    4.560284
-0.1 / 16.33139    4.57685
-0.1 / 16.33139    4.593714
-0.1 / 16.3314    4.609998
-0.1 / 16.33139    4.626548
-0.1 / 16.33139    4.643115    // but it seems not much changed, why?
-0.15 / 10.51222    4.659858
-0.15 / 10.51222    4.676248
-0.15 / 10.51222    4.692952
0 / 27.69298    4.759083       // this is when I stopped the mouse. It's reset.
0 / 27.69298    4.775648

As you see the above log, first time, it prints 27.692.. and it's original x rotation of spine.

Next, I moved my mouse so the "horzMovement" value was updated to minus, and it updates x localRotation also.

But when I stopped move mouse, it just return to initial x rotation 27.69298!

There is no code or functionality to "rotating back" to original rotation of spine. I don't know why this is happening. Wham am I missing?

Any advice will very appreciate it!!


texts: How do you solve where the camera should be on a bezier curve depending on player? (camera on rail)

texts:
I am writing a game where I require a camera on rail; That is, the camera's path is fixed and follows a bezier curve. However, I cannot find any resources online for solving the closest point on a bezier curve closest to another arbitrary point, despite being something that should be common.

A good example of a game that does it very well is the original Crash Bandicoot trilogy.

So how do you do it? Or am I overthinking the problem?


texts: SDL Audio/Mixer cannot initialize with 2 channels only

texts:
From the documentation using SDL2 Mixer to init the soundcard with 2 channels.
It will return 8 channels (7.1) and seems there is no way have just 2 channels.
here the snippet that i used simple as that:
Mix_Init(0);
    if (Mix_OpenAudio(44100, AUDIO_S16, 2, 1024) < 0) {
        cerr << Mix_GetError();
        return -1;
    }

int freq;
uint16_t fmt;
int channels;
if (Mix_QuerySpec(&freq, &fmt, &channels) == 0) {
    cerr << "query return 0" << endl;
}
cout << "freq: " << freq << endl
    << "format: " << fmt << endl
    << "channels: " << channels << endl;

and channels are equal to 8.
MY soundcard is a 7.1 so make sense, but shouldn't be init as stereo (2 ch) if required so?
Any help how to "force" to have just 2 channels?
It seems like is my driver doesn't support normal stereo, that is quite weird to me.
Any help would be appreciated


texts:
For game saving purposes, I'm keeping track of references to ScriptableObjects through a lookup table, so that I can serialize/deserialize using the SO's position in that table. I have a lot of individual SOs that I want to be able to serialize, so I wrote an editor script to populate that table automatically. The table exists in a MonoBehaviour on a prefab.
Originally, I wasn't saving the prefab, because in the inspector it looked like the changes were successfully applying. However, those were showing in-memory changes; when you open the asset, the changes don't exist. The problem is, when I added the line to save the asset (PrefabUtility.SavePrefabAsset) Unity started hanging at the end of every import while showing that it was importing SO Lookup Table. I feel like I'm missing something obvious here, but Google hasn't been any help. What's wrong with my code?
Here's the editor script. Every time assets finish loading, it adds any ScriptableObjects that aren't in the lookup table and exist in one of the specified directories, and removes any that were deleted from or moved out of those directories.
public class SOLookupTableAutoPopulator : AssetPostprocessor
{
    const string SO_LOOKUP_TABLE_PATH = "Assets/Prefabs/SO Lookup Table.prefab";

    // every ScriptableObject in these directories is automatically added to the lookup table prefab
    static readonly string[] DIRECTORIES_TO_TRACK = new string[]
    {
        "Assets/ScriptableObjects/ExampleDirectory1",
        "Assets/ScriptableObjects/ExampleDirectory2"
    };

    static void OnPostprocessAllAssets (string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        var lutPrefab = AssetDatabase.LoadAssetAtPath(SO_LOOKUP_TABLE_PATH, typeof(GameObject)) as GameObject;
        var soLookupTable = lutPrefab.GetComponent<SOLookupTable>();

        // remove first in case asset moved between two tracked directories
        foreach (var path in pathsInTrackedDirectories(deletedAssets.Concat(movedFromAssetPaths)))
        {
            soLookupTable.LookUpTable.RemoveAll(o => o.Path == path);
        }

        var toAdd = pathsInTrackedDirectories(importedAssets.Concat(movedAssets))
            .Where(p => AssetDatabase.GetMainAssetTypeAtPath(p).IsSubclassOf(typeof(ScriptableObject)));

        foreach (var path in toAdd)
        {
            if (!soLookupTable.LookUpTable.Any(o => o.Path == path))
                soLookupTable.LookUpTable.Add(new ScriptableObjectPathTuple(path));
        }

        PrefabUtility.SavePrefabAsset(lutPrefab);
    }

    static IEnumerable<string> pathsInTrackedDirectories (IEnumerable<string> pathList)
    {
        return pathList.Where(p => DIRECTORIES_TO_TRACK.Any(d => p.StartsWith(d)));
    }
}

The lookup table looks like this:
public class SOLookupTable : MonoBehaviour
{
    public List<ScriptableObjectPathTuple> LookUpTable;

    public int GetID (ScriptableObject so)
    {
        return LookUpTable.FindIndex(o => o.Asset == so);
    }

    public ScriptableObject GetSO (int id)
    {
        return LookUpTable[id].Asset;
    }
}

And here's the class that the lookup table contains. I track the path in addition to the asset itself for the deletion phase of OnPostprocessAllAssets - you can't retrieve an asset from a path that points to a deleted asset.
[Serializable]
public class ScriptableObjectPathTuple
{
    public ScriptableObject Asset;
    public string Path;

    public ScriptableObjectPathTuple (string path)
    {
        Path = path;
        Asset = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as ScriptableObject;
    }
}


texts:
I'm working on converting a dx11 shader from a .fx file for use in Unity3D and I'm a little puzzled by the HLSL Buffer<> type declared in the shader. More specifically, what are these and how can I implement them in Unity? I'm aware of the Structured, Append, and Consume Buffers but those appear to be different then this and the Microsoft documentation wasn't to helpful. Is it just like an array that is populated and sized from code before getting assigned to the shader? Are they read only or writable as well?
So far I'm thinking the closest approximation I can use is a StructuredBuffer but the .fx file has its own declaration for that as well so I'm not entirely sure I should go that route.

Example:

Buffer<float4> g_someData : register(t18);


texts: How to throw an object without having a curve trajectory?

texts:
I am making a game that slingshots an object using a line renderer. I wanted to know how I can throw my object when I unclick my mouse without having a curve trajectory like throwing a basketball to a ring. I already coded some script that will make an object throw but with a curve.
Here's an example that I want to achieve?
RED - How I want my object to happen.
BLUE - How I don't want my object to happen.

CODE

public float power;
public Vector2 minPower;
public Vector2 maxPower;

Vector2 force;

void Update()
{
    MouseControl();
}

void MouseControl()
{
    //When touched
    if (Input.GetMouseButtonDown(0))
    {
        //CODE
    }

    //When touch is hold
    if (Input.GetMouseButton(0))
    {
        //CODE
    }

    //When touch is release
    if (Input.GetMouseButtonUp(0))
    {
        force = new Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x),
        Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y));

        myBody.velocity = force * power;
    }
}


texts: Is Unity 5.6 NavMesh Data Available to Gizmos/Editor?

texts:
I have a script from Dungeon Architect that basically draws Gizmo lines along all connections between neighboring waypoints, which is nice.  However, I'd like to draw a secondary line the follow the lowest cost path on the NavMesh between two points (in the scene view as a gizmo, preferably).  There's a sample I'm trying to work from here:

https://docs.unity3d.com/ScriptReference/AI.NavMesh.CalculatePath.html

However, if I debug through it, path never gets any values.  I created agents on the objects at the two points, thinking maybe that would make a difference (I'm not sure why I thought that).  Does this script need to be attached to one of those points?  With a NavAgent?  Or am I missing something completely obvious?


texts:
Without using any of the standard Inform libraries, what is the minimal amount of code / infrastructure needed to support the <action> syntax?

What I tried is

Verb 'foo' * -> Foo;

[ FooSub;
    "Hello from FooSub";
];

[ Main;
  <foo>;
];

I expected this to print Hello from FooSub when run; however, the output I get is

Action <0 0 0>


texts: Why Godot over Cryengine, UE4, Armory3d or Unity3d?

texts:
Godot have a low performance in linux systems and lack of functionalities? This appear not been in account when peoples vote for him over other engines and i wonther whi.
I know it is under MIT lisence, but the others engines have a very permisive licences and in some cases they help you with funding for your games.
I ask this because i have maded survey on google plus about a selection of engines, and people still bote for godot over other engines. I want to select an engine for my future games, and when i compared, godot's not get a good place.