texts: Animation via AnimatorController created in script does not play in Unity

texts:
I have created an empty GameObject and assigned it a script: Main.cs.

public class Main
{
    [MenuItem("Custom workflow/Initialize")]
    static void Initialize()
    {
        // Place a text mesh on the scene
        var obj = new GameObject("Sample");
        obj.transform.position = new Vector3(0, 0, 0);
        var text = obj.AddComponent<TextMesh>();
        text.text = "Hello world";

        AnimationClip clip1 = CreateAnimationClip();
        AnimatorController sm = CreateSimpleAnimatorController(clip1);

        var animator = obj.AddComponent<Animator>();
        animator.runtimeAnimatorController = sm;
        animator.applyRootMotion = true;
    }

    private static AnimationClip CreateAnimationClip()
    {
        var translateX = AnimationCurve.Linear(0.0f, 0.0f, 2.0f, 25.0f);
        var animationClip = new AnimationClip();
        animationClip.SetCurve("", typeof(Transform), "position.x", translateX);

        AssetDatabase.CreateAsset(animationClip, "Assets/procanim.anim");

        return animationClip;
    }

    private static AnimatorController CreateSimpleAnimatorController(
      Motion motion1 = null, Motion motion2 = null)
    {
        // Creates the controller
        var controller = AnimatorController.CreateAnimatorControllerAtPath(
          "Assets/SimpleStateMachineTransitions.controller");

        // Add parameters
        controller.AddParameter("GoToB", AnimatorControllerParameterType.Bool);
        controller.AddParameter("GoToA", AnimatorControllerParameterType.Bool);

        // Add StateMachines
        var rootStateMachine = controller.layers[0].stateMachine;

        // Add States
        var stateA1 = rootStateMachine.AddState("stateA1");
        stateA1.motion = motion1;
        var stateB1 = rootStateMachine.AddState("stateB1");
        stateB1.motion = motion2;

        // Add Transitions
        var transitionAB = stateA1.AddTransition(stateB1);
        transitionAB.AddCondition(AnimatorConditionMode.If, 0, "GoToB");
        transitionAB.duration = 0;

        var transitionBA = stateB1.AddTransition(stateA1);
        transitionBA.AddCondition(AnimatorConditionMode.If, 0, "GoToA");
        transitionBA.duration = 0;

        return controller;
    }
}

The problem

As I invoke the menu item, I get all assets in place. When I hit play, nothing happens. I can see state stateA1 is on, but the animation does not run. If I click on the text object in the scene...

...this is what I see in the animation window:

I think the problem might be here:

animationClip.SetCurve("", typeof(Transform), "position.x", translateX);

Because, when I remove the code generate Transform.position property from the animation timeline and manually add one via UI, it works once I hit play again.


texts: what is more expensive 2D sprites or 3D models?

texts:
Me and my friends are programmers.We decided to try ourselves in game design. As we don't want to find ourselves in debts, we decided to avoid investors. We want to develop and publish a couple of simple 2D games to test the ground. So we collected some humble funds to pay artists and for some other stuff like Unity.

The question is: what is more expensive - 2D sprites or 3D models for 2D games (not mega visual rich)? The question is adressed to artists and modelers and to everyone who has expirience hiring them. Thanks in advance!


texts: Unity - Plugin 'MFC100U.DLL' is used from several locations:

texts:
As per subject, I got this error message using Metaio SDK in Unity5. BTW, I'm using Mac, not Windows machine.

Plugin 'MFC100U.DLL' is used from several locations:
 Assets/Plugins/x86_64/MFC100U.DLL would be copied to <PluginPath>/MFC100U.DLL
 Assets/Plugins/x86/MFC100U.DLL would be copied to <PluginPath>/MFC100U.DLL
Plugin 'MSVCP100.DLL' is used from several locations:
 Assets/Plugins/x86/MSVCP100.DLL would be copied to <PluginPath>/MSVCP100.DLL
 Assets/Plugins/x86_64/MSVCP100.DLL would be copied to <PluginPath>/MSVCP100.DLL
Plugin 'pthreadVC2.dll' is used from several locations:
 Assets/Plugins/x86/pthreadVC2.dll would be copied to <PluginPath>/pthreadVC2.dll
 Assets/Plugins/x86_64/pthreadVC2.dll would be copied to <PluginPath>/pthreadVC2.dll
Plugin 'Shore140.dll' is used from several locations:
 Assets/Plugins/x86_64/Shore140.dll would be copied to <PluginPath>/Shore140.dll
 Assets/Plugins/x86/Shore140.dll would be copied to <PluginPath>/Shore140.dll
Plugin 'MSVCR100.DLL' is used from several locations:
 Assets/Plugins/x86/MSVCR100.DLL would be copied to <PluginPath>/MSVCR100.DLL
 Assets/Plugins/x86_64/MSVCR100.DLL would be copied to <PluginPath>/MSVCR100.DLL
Plugin 'metaiosdk.dll' is used from several locations:
 Assets/Plugins/x86/metaiosdk.dll would be copied to <PluginPath>/metaiosdk.dll
 Assets/Plugins/x86_64/metaiosdk.dll would be copied to <PluginPath>/metaiosdk.dll
Please fix plugin settings and try again.

UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

How I can fix this error? Please advice. Thank you.


texts: C++ SDL2: How to join two windows in one: top_Window + bottom_Window?

texts:
I have a code where the camera scroll left, right, up, down, and I would like to add a progress bar similar to the one below at the bottom of my window

Is it possible to create the progress bar in a different window and then join my top game window with this new window, so they can render at different times? If not (by using only one window) when scrolling up and down I would have that progress bar in the way, indeed my camera is set to the exact dimension of window height and window width and currently works flawlessly without that bar because the bar is not part of my current texture.
Any suggestion how to join two windows in one? I have created the bottom_Window so far (so I can try to develop the progress bar) but I want it to be fully merged with the top one (the actual game) so they can be moved at the same time)
Many thanks!


texts:
This picture is from one of Dirk Gregorius' presentations:

The original diagram has only one contact point (the red one). The r_1 and r_2 vectors are required to produce rotation while solving the contact constraints. I agree that the r_2 vector is correct, but I think that the r_1 vector should point towards the blue point (which I've added myself)
It's not difficult to retrieve the blue point (just add the minimum translation vector to the red point), but I've seen contrasting depictions of what points the contact manifold consists of.
Excluding the parallel edge-edge case, should the contact manifold consist of two points (the deepest points of each shape) or just one?


texts: How would one render dynamic vertices in OpenGL ES 2.0 like in a 3D modeling program?

texts:
Is there an easy way to re-render dynamic vertices in OpenGL ES 2.0 so that one could, for example, make a modeling program?

I understand how to make a dynamic vertex array, but what I don't understand is how to re-render a dynamic array, I've only seen examples where you have to re-compile a shader each time you make an array.

I did find the function:

glBufferSubData();

does this update the data without having to recompile the shader?


texts:
What is the proper way to process joystick input?

Take, for example, the Xbox One controller. XInput returns joystick input along the x and y axis. I'm not sure if the hardware just measures voltage across the two axis, or not; I'm not very knowledgeable, in the hardware domain.

I'm unsure what data processing is done by API's like XInput already - but since the dead zone is still prevalent, I'm assuming XInput does very little input massaging. This leaves me with a few questions:

Should the dead zone be clipped circularly or rectangularly?
What type of low-pass filter should be applied, if any? Perhaps a moving average should be applied?
Should a bias be introduced into the input based on the resting input?


texts: LibGDX - Actors added to a stage from a network thread are not drawn

texts:
I have an application with several Screen and Actor. On my main screen, the actors added to the stage during creation are rendering fine.
However, I have a Netty server running, and when it receive certain events, it adds, in the network thread, new actors to the stage. These are never drawn, despite the main thread continuing to call the render function of the corresponding screen.
In the code below, if I call recieveInbound from the Screen's show by mocking the exact same network payload, the actors are drawn as expected.
What am I doing wrong?
MainScreen.java
// ...

public MainScreen(Game game) {
    batch = game.getBatch();
    viewport = game.getMainViewport();
    stage = new Stage(viewport, batch);

    try {
        capabilities = GL.getCapabilities();
    }
    catch (IllegalStateException e) {
        capabilities = GL.createCapabilities();
    }
}

/**
 * Receives and manages signals from the remotes.
 *
 * @param code The received code
 * @param object The received payload
 */
public void receiveInbound(int code, Object object) {

    // Restore OpenGL context if needed before processing.
    try {
        GL.getCapabilities();
    }
    catch (IllegalStateException e) {
        GL.setCapabilities(capabilities);
    }
    // LOGGER.debug(stage.getActors().size); <-- 1 added in show, as expected
    if (code == 10) {
        LevelMap map = mapManager.serve(code, object);
        stage.addActor(map.getBackground());
        Arrays.stream(map.contentMatrix)
            .forEach(row -> Arrays.stream(row)
                .forEach(stage::addActor)
            );
    }
    // LOGGER.debug(stage.getActors().size); <-- 854, as expected
}

@Override
public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL33.GL_COLOR_BUFFER_BIT);
    batch.setProjectionMatrix(viewport.getCamera().combined);
    // Expected position, actors are around there.
    viewport.getCamera().position.set(0,0,0);
    stage.act();
    stage.draw();
}


texts:
I am interested in making a simple 3D game this summer, and I'd prefer if it were playable in a browser. My choices I am considering are Unity and WebGL. Currently I have no experience in either. But I have taken an introduction course to OpenGL. As well I will later be taking a course that will use Unity. I have some C# experience, but no web background.

The factors I'm considering are ease to learn and the penetration each has. I know Unity games can be uploaded to Kongregate, which seems like a pretty big deal if I made a game that would be somewhat successful. But of course that may not be the case at all.

Which way should I lean? Personally I think learning WebGL would be the easiest transition, but I am not sure


texts: Ridiculous Error on Unity 5.6.4p4 Method Name doesn't exists

texts:
I am facing a strange issue on Unity version 5.6.4p4
The code compiles and runs just perfectly fine in editor but when I build it for android I see an error message saying that my method doesn't exists. I have checked many times but there is no such issue. I am not doing anything wrong. Can anyone suggest what could be wrong ?


texts:
I am a newbie in gamedev, and I don't know about programmer's problems that can appear during development.

So can you advice me some best practice for starting build new online multi-player game backend?

I just saw reddraft server, and I think Spring library can also do some of its features. What is big difference? Do I need learn more spring or I have to use servers like reddraft or write these tools myself?

I know that I need to learn hard and many - and the question is - what I should to learn now at the beginning?

Thanks.


texts: What is a good algorithm to detect collision between moving spheres?

texts:
If (for the purpose of collision detection) 3D objects are represented in a game by spheres, what is a good algorithm to detect a collision between spheres?

If each object has a position as of the last frame and a new (desired) position, what is a good algorithm that will identify collisions where the spheres didn't intersect in the previous frame, and they may not intersect in the second frame, but they did intersect somewhere in between?


texts: How should I design my particle system to make it easy to add new particle effect types?

texts:
Recently I started designing a particle system for a game I develop. But I have some issues with it. I mean, it works but I have a feeling that my design isn't good enough.

So, basically I have a Particle class which contains the particle's vars and couple of functions:

class OBJECTATTRIBUTE_API Particle
{
protected:
     Vector3d position;
     Vector3d direction;
     Vector3d gravity;

     float life;
     float fade;

     float red;
     float green;
     float blue;

     bool isActive;
     bool isInit;

public:
     void Deinitialize();

     void SetPosition(Vector3d position);

     bool IsActive();
};

And I derive from that class the types of particles. Like this:

class OBJECTATTRIBUTE_API ParticleExplosion : public Particle
{
public:
    void Initialize();

    void Update();
    void Render();

    void Rejuvenate();
};

And at the end is the emitter. This is actually where I think my design fails. I make an emitter for every particle system and, at some point, I may have too much different emitters.

Here is an example of the particle emitter realisation:

// The base class
class OBJECTATTRIBUTE_API ParticleEmitter
{
protected:
    Vector3d emitterPosition;

    unsigned int particleTextureID;
    unsigned int particleCount;
    bool isEmitterStopped;

public:
    ParticleEmitter();
    ParticleEmitter(Vector3d emitterPosition);
};

// The derived emitter.
class OBJECTATTRIBUTE_API ParticleEmitter_Explosion : public ParticleEmitter
{
private:
   ParticleExplosion *particles;

public:
   void AddParticles(unsigned int particleCount);

   void Initialize();

   void Start();
   void Stop();

   void Reposition(Vector3d newPosition);
   void SetParticleTextureID(unsigned int particleTextureID);
};

And the question - Is my particle system design good? If not, what can I do to improve it?

EDIT : I was told that the question was too subjective, so I will try to add couple of specifications.

Firstly, I started making the particle system for explosion simulation and also some attack animations in my game. It works very well with that, so I think this goal is achieved.

Secondly, the performance hit is acceptable and I am OK with that.

And finally, the question was about is this design good for flexible adding of new particle effects implementation?


texts:
If I want to make a character (in Blender) made of cubes, to export it to unity later, should I leave these cubes and all the other body parts as separate objects, or join them all into one mesh?

And, If I should join them - is it a good idea to leave the cubes elements inside of each other?

Or I should remove them, add some loops and connect the vertexes?

In the last case it will be difficult to keep the cubes surfaces flat, because of the vertex shifting during joining.


texts: Can I develop a game for Kinect without a Kinect?

texts:
I have to make a game in Unity3D using Kinect. The problem is I don't have the Kinect yet. I need to wait until they deliver it to me.

Can I imitate Kinect's movement for debugging my app?


texts: Question About An Implementation Of Parallax Scrolling In C++/SDL/OpenGL

texts:
I been working in a project with a team for a Software Engineering class and we think that using the parallax scrolling will help our game to look really nice but we are not really sure if our idea for implementation it's the correct one, so I hope that someon will give us some guidance about our plan.

First, we have three classes, Level, Tileset, Layer, the first one has two vectors of Layers and Tilesets, so our idea is load all the data from a TMX file of the first level in a vector>, but we only draw the part of the map that it's currently in camera, so inside a cycle we draw every layer, but we're not sure how defined a velocity for each layer so the parallax scrolling works like it supposed.

Thanks for the attention and help.

Good day....

PD: If someone need more information, don't doubt in ask.


texts: Increasing mass in ineleastic collision by orders of magnitude resultsin little change in velocity

texts:
When increasing my rocketMass from 10 to 1000 or to a 1000 or bringing my shipMass down to 1, I notice very little increase in how far the ship's final inertia is. I'm expecting that increasing from 10 to 1000 will be visibly about 100 times faster.. but it's not. If I multiply the hypotenuse at the end, that does make the bouncing incredibly faster.

Am I misunderstanding physics or is this a calculation error?

handleCollision(r) {
    var angle = r.r * Math.PI / 180.0;
    var rr = this.r * Math.PI / 180;

    var rocketVector = {'x' : r.power * Math.cos(angle), 'y' : r.power * Math.sin(angle)};
    var inertiaVector = {'x' : this.magnitude * Math.cos(rr), 'y' : this.magnitude * Math.sin(rr)};

    var rMass = 100;
    var shipMass = 1;

    var x = (rMass * rocketVector.x) + (shipMass * inertiaVector.x);
    var y = (rMass * rocketVector.y) + (shipMass * inertiaVector.y);
    var xDividedByMass = x / (rMass + shipMass);
    var yDividedByMass = y / (rMass + shipMass);

    var yRadians = (yDividedByMass * Math.PI / 180);
    var xRadians = (xDividedByMass * Math.PI / 180);
    var theta = Math.atan( yRadians / xRadians);

    theta = theta * 180 / Math.PI;
    console.log(theta);

    var hypotenuse = Math.sqrt((xDividedByMass * xDividedByMass) + (yDividedByMass * yDividedByMass));

    if (x < 0) {
        theta -= 180;
    }

    this.r = theta;
    if (this.r < 0) {
        this.r += 360;
    } else if (this.r > 360) {
        this.r -= 360;
    }
}


texts:
Im using XNA 4.0 with the BEPU physics engine v1.2 and I have encountered some performance problems on Xbox. Im not sure if the my mesurements are an expected result of the Xbox (with alot of dynamic physics objects). So I wonder if anyone else thinks the numbers are fair or not?

Here's my mesurement:

Im runing a simulation with 100 dynamic boxes and a static plane as my ground. Now this sim is multithreaded on hardware threads 1, 3, 4 and 5 (Xbox) and I see a significant perf boost because of that. However the performance of the simulation varies between 3-5.5 ms for resting objects on the 360.
Is that not way to much or is it fair? The PC version runs the sim at about 0.7-1 ms. However that version is multithreaded over 8 cores. But it's still a very big leap.


texts: Efficient way to build a 360 rotation system with clockwise and counterclockwise direction

texts:
I've been struggle with rotation for sometime now, maybe it isn't that hard for someone who dominates the mathematical side of things regarding rotation and angles but, I need to build a rotation system that rotates the player to either clockwise or counterclockwise direction according to the nearest direction to the target angle.
I.E.
If my player is rotated to 45° and the direction is changed to 135°, he must rotate 90º clockwise (from 45° to 135°).
If my player is rotated to the same 45° and the direction is changed to 315°, he must rotate 90° counterclockwise (from 45° to 315º).
This didn't seemed a big deal when I started, but it's been hard for me to build something that cover all the rotation possibilities, which tells me that I'm doing something wrong here. I mean, there's must be a couple of formulas that fit this problem and cover all the possible rotations or something.
Right now, my rotation system is configured to a minimal of 5 degrees of rotation, wich means that the possible degrees goes from 0 to 355(it never get to 360, going back to 0 instead).
I don't have a code to show cause everytime I try to build this, I reach to a point where there are so many possibilities that aren't covered by my tests that I end up deleting everything to try again, but I'm tired of this seemingly endless loop (for me anyway lol).
Does anyone knows a way to build this?
-EDIT-
My project is 3D and the camera perspective is similar to sports games like NBA 2K or soccer games in general. The input is a Vector2 obtained with the new input system. I need to move my player around with root motion, which means that my goal with this system is to calculate the rotation data to be passed as an animation parameter (using a event), so the correct animation is played and the player finally rotate according to the animation. The main part of the code (calculation part) was built by a friend of mine, who has more knowledge than me. This is my current code:
if (movementVector != Vector2.zero)
    {
        targetRotationAngle = Mathf.Atan2(movementVector.x, movementVector.y) * Mathf.Rad2Deg + cameraTransform.eulerAngles.y; //FUNCTIONAL CODE BUILT BY A FRIEND
        targetRotationAngle = Mathf.CeilToInt(targetRotationAngle / 5) * 5; //FUNCTIONAL CODE BUILT BY A FRIEND
        if (targetRotationAngle < 0)
            targetRotationAngle += 360;
        if (currentRotationAngle == targetRotationAngle)
            return;
        else
        {
            if (currentRotationAngle < targetRotationAngle)
            {
                Debug.Log("Clockwise rotation in " + (targetRotationAngle - currentRotationAngle) + " degrees");
            }
            if (currentRotationAngle > targetRotationAngle)
            {
                Debug.Log("Counterclockwise rotation in " + ((360-currentRotationAngle)+targetRotationAngle) + " degrees");
            }
        }
            currentRotationAngle = targetRotationAngle;
    }

This is a summarized version of my previous attempts (the ELSE part), I know my formula is wrong, cause it doesn't cover all the rotation scenarios, the more I tried to build, more of this IF's were nesting. That's why I've decided to ask...


texts:
I'm very new to the world of Computer Graphics, and I'm struggling to find resources to help me understand how to draw my mesh (I have loaded everything into vertex and index buffers), I am not using a 3D API, instead I am just using C# and a 2D Graphics canvas to draw my mesh.

Everything is currently loading, but I have suspicions that I am reading my faces in as quads instead of triangles, could somebody A) Clarify whether I am draw a quad instead of a triangle B) If I am drawing quads, how do I draw a triangle? This has been a headache for me for a few hours...

for (int i = 0; i < m_numFaces; i++)
{
     Face face = m_meshData[i];

     // Draw the face
     for (int j = 0; j < 3; j++)
     {
                m_graphicsContext.DrawLine(m_pen,
                     // Get the X,Y points of this face
                     (int)face.GetPointAtIndex(j).points[0],
                     (int)face.GetPointAtIndex(j).points[1],
                     (int)face.GetPointAtIndex(j + 1).points[0],
                     (int)face.GetPointAtIndex(j + 1).points[1]);
     }
                // Draw from first point back to last line
                m_graphicsContext.DrawLine(m_pen,
                     (int)face.GetPointAtIndex(2).points[0],
                     (int)face.GetPointAtIndex(2).points[1],
                     (int)face.GetPointAtIndex(0).points[0],
                     (int)face.GetPointAtIndex(0).points[1]);
}


texts: Unreal Engine - How can I add blur effect at my Camera in iOS

texts:
I have requirement to add blur effect at my camera in specific point , it work just fine in pc but when I deploy in my phone it remove the effect

According to documentation

  To turn off Depth of Field, set "Scale" to zero, this is suggested as
  default to improve performance.

  Mobile Depth of Field is currently not compatible with PC. There is no
  way to currently visualize on the desktop version what the mobile
  settings will look like except using an unsupported "-FeatureLevelES2"
  launch flag when starting the editor, or using the "Mobile Preview"
  option from the "Play" button drop down menu.

But when I run in my mobile this effect disappear

any one know the reason

here is my Camera setting


texts: Javascript/HTML5 canvas: Integrate scrolling tilemap with map server

texts:
I am playing around adapting the example code at Mozilla Dev Network: Square tilemaps implementation: Scrolling maps to fit with a server I wrote myself. There's a link to the original source code at the bottom of the page.

Instead of hard-coding the map (and its layers) into the js page, I can have a server call deliver the map data in a similar format (a 1-dimensional sequence of numbers up to 256). The way the server (and the js interface) is constructed, I first need to get the map Id from the game that is stored on the server and use that id to get (a section of) the map.

This is the function for doing the data fetch:

function LoadGame(gameid) {
$.getJSON('/api/game/' + gameid)
    .done(function (game) {
        if (game !== null) {
            mapid = game.MapId;
            map = AssetLoader.LoadMapSection(mapid, 0);
        }
        else
            console.log("Could not load game with id: " + gameid);
    })
    .fail(function (jqXHR, status, error) {
        console.log(error);
    });
}

The LoadMapSection function looks like this:

AssetLoader.LoadMapSection = function (mapid, pos) {
    if (!(mapid in this.maps)) {
        this.status = statusEnum.LOADING;
        console.log("Loading map section: " + mapid + " at: " + pos);
        $.getJSON('/api/map/section/' + mapid + '/' + pos + '/32/24')
            .done(function (map) {
                AssetLoader.maps[mapid] = map;
                this.status = statusEnum.DONE;
                console.log("Loaded section of map: " + mapid);
            }).fail(function (jqXHR, status, error) {
                console.log(error);
                this.status = statusEnum.ERROR;
            });
    }
    return map;
}

Since the map data may take some time to arrive I am trying to use an AssetLoader, suggested by MDN, to fetch the map data as well as the spritesheets for displaying the map. So, upon game load, I construed this:

Game.load = function () {
return [
    AssetLoader.LoadImage('atlas-elevation', 'assets/atlas/elevation.png'),
    AssetLoader.LoadImage('atlas-landscape', 'assets/atlas/landscape.png'),
    LoadGame(gameid),
   ];
};

To ensure the asynchronicity and wait for all data to be fetched, the following code has been left unchanged:

Game.run = function (context) {
    this.ctx = context;
    this._previousElapsed = 0;
    var p = this.load();
    Promise.all(p).then(function (loaded) {
        this.init();
        window.requestAnimationFrame(this.tick);
    }.bind(this));
};

So the following init-call is supposed to happen after that:

Game.init = function () {
    Keyboard.listenForEvents(
        [Keyboard.LEFT, Keyboard.RIGHT, Keyboard.UP, Keyboard.DOWN]);
    this.tileAtlas = AssetLoader.GetImage('atlas-elevation');
    this.camera = new Camera(map, 512, 512);
};

However, I keep on running into situations where the map is still "undefined" as soon as the Camera code is hit:

function Camera(map, width, height) {
    //if (map != null) {
        this.x = 0;
        this.y = 0;
        this.width = width;
        this.height = height;
        this.maxX = map.Width * scale - width;
        this.maxY = map.Height * scale - height;
    //}
}

I did declare map at the top of the js file as global variable, so I am not sure where I am going wrong here.


texts: Is it reasonable to ask for all rights for music when hiring a musician?

texts:
I've made a game and now I need to add real sounds and music to it. For the first time I've decided to hire a musician to make music for my games. Before I used to buy sound packs and licenses for tracks.

The negotiations didn't go well as the price was too high for me and the artist didn't like the idea of selling me the music and wanted to only license it to me.

I'd like to know if I've made a mistake or if I've been unreasonable.

Just to be specific, we're talking about 6 tracks, 90 seconds long each. The music is chip-tune done by one musician (that's important since I understand that hiring an orchestra would cost more than hiring just one person).

What I wanted was to get the tracks with all the rights, other than the authors rights - putting their name in the credits.

I've been told that nobody does this and the musician always keeps the rights to later sell OST etc. And if I want all the rights, one track would cost me $500. And even just getting a one-title license would cost me $200.

I have no idea if that's a standard market price, it seems high for me.

Is the price reasonable?
Is it unreasonable for me to ask for music with all the rights?


texts: Can I give vehicles its real names? (e.g. Skoda, Tatra)

texts:
I'm working on a simulator of old USSR transport.

But my boss is telling me that I can't put real names on vehicles, but don't get me any proofs of it. I know that you can't put real human names and company emblems, but I didn't find any info on transport names. I often see real-life naming in other simulators, but they come often as mods (exception is Subtransit).

Any thoughts on it, is he right or wrong (I don't intend to use logos of the transport)?


texts:
I am developing a game where objects move in the screen. My object is instantiated in Y = 0 and I want to destroy this object when it goes under the screen Height.
So if (positionY >= ScreenHeight) I have to destroy this object to clean my game and prevent "lag".

How to do this? I have a dispose method (this.dispose) but it cause the dispose of the app and I want destroy only the object.

Thanks in advance


texts: How to Make Snaky Inchworm Motion With Armature Staying Upright

texts:
I have a series of connected bones in a straight line. I want to be able to rotate each bone vertically and/or horizontally so that it can slither and arch randomly kinda like a snake mixed with an inchworm. When I do this, however, the axes get entirely botched. If I rotate one bone horizontally (i.e. on Y), then vertically (i.e. on X), then back horizontally the the other way, the bone is now rotated on the third axis (i.e. Z). This is further compounded when all the bones are trying to do the same thing. How can I keep these pieces "upright" while doing all these random rotations?

Edit:
I think it comes down to this concept. If transform.right = (0.9, 0.2, -0.4) and transform.forward is (-0.3, -0.2, -0.9), how do I calculate how much I should rotate about transform.forward to make transform.right = (x, 0, z) from (0.9, 0.2, -0.4)?


texts:
I have been attempting to make a game engine in C++ and have come across the dilemma of game state management. I have done a lot of research and found numerous ways of accomplishing from game engine with derived classes to using enums and I would like to know the most effective/efficient way of managing game states.

EDIT
I would like to know how other people implement their game state management, i.e. what you like the most and why you like it. Also, any tutorials/code examples that are generally about game state would also be much appreciated.


texts: Collision detection: Swinging bat/racket and ball

texts:
I am programming a side-view tennis game, inspired by an old arcade game,
using Javscript and HTML5 canvas elements. The player can move left and right and holds a racket at arms length which can be rotated 360 degrees around the shoulder joint.

I am quite happy with the collision detection and resulting deflection angle between the racket and the ball in the case where the player stands still and the racket does not move. I use a ray-casting approach for this collision detection between the vector that represents the racket and the trajectory vector for the ball as proposed here.

However, I am having trouble implementing the collision detection between the rotating racket and the ball. When the racket is swung, the area in which a collision would apply has a shape similar to a circular segment , but the racket rotates rotates to fast and the collision detection does not pick it up in most cases.
The image bellow illustrates the problem, the red arrow indicates the direction of the swinging racket.

The following code snippet from the player entity's update function shows how the racket is updated. arcmx and armcy is the location of the shoulder joint, rstart_ and rend_ are the beginning and end of the racket.

  if(KEY_STATUS.rleft || KEY_STATUS.rright) {
    if(KEY_STATUS.rright) {
      this.rangle += this.rspeed;
    } else if (KEY_STATUS.rleft) {
      this.rangle -= this.rspeed;
    }
  }

  this.armcx = this.x + this.width/2;
  this.armcy = this.y + 46;
  this.rstartx = this.armcx + Math.cos(this.rangle)*40;
  this.rstarty = this.armcy + Math.sin(this.rangle)*40;

  this.rendx = this.armcx + Math.cos(this.rangle)*71;
  this.rendy = this.armcy + Math.sin(this.rangle)*71;

I am pretty lost on this problem and appreciate any hints on how to approach it.


texts: Unity: object with strange transparent color?

texts: In my game the players left arm is this weird transparent color, but the right is normal. When i drag the right arm's material over to the left it doesn't fix the problem, so there's something wrong with the object itself not the material. How do i fix this?


texts: How can I support different resolutions with Monogame?

texts:
I want to support the following 4 resolutions in my Windows Phone 8 game: 480 × 800, 768 × 1280, 720 × 1280, 1080 x 1920.
How can I do that with Monogame? If I draw a sprite with Monogame, the sprite is not drawn on the right place in every resolution. For example, with a resolution of 768 × 1280, the sprite is drawn in the center of the screen, but if I use another resolution, the sprite is no more drawn in the center of the screen.

What should I do so that the sprite is in every resolution on the same place?


texts: iOS Game that Runs Continuously in Background

texts:
I'm trying to understand the most logical way of creating an iOS game that runs continuously in the background.

For example.. you have tower and enemy waves. The game has endless enemy waves even when the game exits. When you open the game again, it will retrieve the data that occurred when the app was closed.

I assume a database on a server would be the best solution. The values continuously increment on the server. The game connects to the server and retrieves the specific user's updated game data.


texts: What is a good file format for saving game data?

texts:
I need to save some custom game data.  Map, player, etc.

All of them will have "sub objects".  For example,  a map and map will have an "array" of tiles.  ie, hierarchical data.  Hopefully nothing binary.

What would be a good format for these?

So far I'ved considered:

Serailization: This is FAST and easy, but tends to break when I change the underlying classes :(

XML: I really hate parsing this.  My test case was over 100+ lines of code and seemed likes tons of "busy work" for even a very simple format.

INI: would be really clumsy for hierarchical data.

Protobuf: Never used it, but read you have to do a lot of manual mucking around and breaks if you change the class.

Other options? That's why I'm here!

Edit: this is Java btw.

Edit 2:

I settled on "Controlled Binary Serialization" (see below).

Pros:

it's fast
it's small (on disk) and can be easily compressed/decompressed during read/write.
it's super easy to read/write from game and toolset.
I can decide what to include/exclude of the object.
Objects/Data can be nested.

Cons:

Can't edit it by hand (like XML, YAML, etc)
Can't easily read/modify it with scripts
Java Serialization by default is pretty slow/bloated compared to other implentations, but it's stable and works


texts: How can C# access JavaScript variables in Unity 5?

texts:
I have a static public boolean in a JavaScript and I want to access it in a C# script. When I tried the way that you would call a static variable from another script though, it said that the variable and script weren't recognized. Here is my JavaScript code:

public static var ItemPurchased = false;
function OnGUI () {
    if (GUI.Button(new Rect(10, 90, 190, 24), "Click here to collect water.")){
         ItemPurchased = true;
}

I do believe that the JavaScript is correct. On the other hand, here is my C# script:

public static bool itemowned = false;
void Update () {
    if(PurchaseItemScript.ItemPurchased == true){
        itemowned = true;
        PurchaseItemScript.ItemPurchased = false;
    }
}

PLZ HELP!


texts:
im implementing a not so simple board game, i have a way to do most stuff (start game handling,turn handling,combat system,movment etc).

im having a problem with spacial cards that players draw,the simple ones like "lose life" or "gain item" etc are simple change to one variable.

but i have rule changing ones ,something like "monster x  you encounter have 2 more life, and if you pass a combat roll gain an item",the first part is just having monsters of said type have 2 more life(changing their stats for the duration of the card.

but changing the combat system to give item on success roll?

should i run an event list every combat move? i dont know how that will work at all.
in real life board game you just do what the card says but in a computer vartion the game shold do it, and im not sure of the logics.

also there is no other resource to consult (ive searched google a lot).

please help me.


texts: How does a game without loading times work?

texts: We're talking about an expansive game that is not divided in levels or checkpoints. A 3D adventure, for example.


texts: How do I keep historical variable value tied to certain period of time?

texts:
I'm currently trying to figure out how I can keep ever-changing variable values
and make it available for other classes to access the said variables.

In my example, I have the following:

public class Item
{
    public int Quantity;
    public int BuyPrice;
    public int SellPrice;
}

The value for all the variables in Item class will change every day.

Let's say I'm entering Day #2, how do I save class Item's variables value for Day #1 so that other classes would be able to refer to Day #1 value on Day #2?

Further to the my earlier question, there will be multiple Vendor classes having their own instances of Item and these Vendor classes will be visited by Agent classes.

I would like for the Agent to loop through all instances of Item sell price owned by the last Vendor it visited. Agent will hold a record of when it last visited the Vendor and will request for Item sell prices on that particular date by that particular Vendor.

Hope that make sense.


texts: Speech recognition in Unity 5 for Android

texts:
I've been working on a game in which the player have to say particular words to perform various tasks. For example, if the player says "boat", a boat pops up in the game. The game I'm building is specifically for offline play, on an Android device. Just for reference, there is a game titled "Pah!" which implemented this offline speech recognition for one specific word. In this game, when you say "pah", the GameObject moves jumps.

I've tried everything from speech-to-text to forums, and even tried Google and used using Windows.Speech, but nothing works. From what I've learned, I need to use the Google speech API for Android speech recognition. I am a bit new, when it comes to Java. I gave it a try and created a basic script, which I thought might take at least one input in speech from the player, but Unity disagrees and says it couldn't recognize the script. I created another script in C#, by taking help from tutorials, but when I switch the platform from Windows to Android it doesn't work, because Unity.Windows.Speech is a Windows namespace

I am blank, and hence, this question. I have googled, visited forums, and even looked at YouTube videos for an answer. I came across a few Unity assets which I paid for, and they are all garbage. If anyone could help me, how do I implement speech recognition in Android, using Unity 5?


texts: SDL2 MOUSEBUTTONUP triggers more then once

texts:
I've been trying to figure this out all day. I'm trying to make a simple check box. But my MOUSEBUTTONUP event keeps firing until I trigger another event like moving the mouse or clicking again.

//If a mouse button was released
if (Sdl_Setup->GetMainEvent()->type == SDL_MOUSEBUTTONUP)
{
    //If the left mouse button was pressed
    if (Sdl_Setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
    {
        //Get the mouse offsets
        SDL_GetMouseState(&mouseX, &mouseY);

        //If the mouse is over the button
        if ((mouseX > Button->GetX()) && (mouseX < Button->GetX() + Button->GetWidth()) && (mouseY > Button->GetY()) && (mouseY < Button->GetY() + Button->GetHeight()))
        {
                //Set the button sprite
                state = selected;
                Button->SetCrop(GetFrameX(), GetFrameY(), state);
                clicked = true;
                std::cout << clicked << std::endl;
        }
    }
}

This will just spam 1 in the console (if you keep the mouse still) when all I want is for it to trigger once. From what I've read MOUSEBUTTONUP is only supposed to be sent to the event queue once

I've tried adding a bool to stop it after it's clicked by putting it in an if statement and that works but the thing is I want to be able to toggle the box on and off so when I add an else statement that changes the bool back to false it spams 101010 instead of just one.

   //If a mouse button was released
if (Sdl_Setup->GetMainEvent()->type == SDL_MOUSEBUTTONUP)
{
    //If the left mouse button was pressed
    if (Sdl_Setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
    {
        //Get the mouse offsets
        SDL_GetMouseState(&mouseX, &mouseY);

        //If the mouse is over the button
        if ((mouseX > Button->GetX()) && (mouseX < Button->GetX() + Button->GetWidth()) && (mouseY > Button->GetY()) && (mouseY < Button->GetY() + Button->GetHeight()))
        {
            if (clicked == false)
            {
                //Set the button sprite
                state = selected;
                Button->SetCrop(GetFrameX(), GetFrameY(), state);
                clicked = true;
                std::cout << clicked << std::endl;
            }
            else
            {
                //Set the button sprite
                state = noInteraction;
                Button->SetCrop(GetFrameX(), GetFrameY(), state);
                clicked = false;
                std::cout << clicked << std::endl;
            }
        }
    }
}


texts: Unity-Animation parameters are not being set

texts:
I have the following animation controller:

with two parameters of walkingSpeed and Jump. I have the following code which should change the values:

animator.SetFloat("walkingSpeed",0.9f);
animator.SetBool("Jump",true);

and animator is the correctly referenced animator object. However the values that the parameters are set to do not appear to change in the animator window, nor do they appear to impact what is happening on the screen. However they do seem to impact the values obtained when doing the following:

animator.GetFloat("walkingSpeed");

The animator consists of the shown blend tree, which works correctly and is always active, however due to the values not being changed it does not blends, and always acts as if the value with which it blends (walkingSpeed is 0).

What is going on?


texts: Is it possible to have a point light cast shadows but no reflection?

texts: I'm working in Unity 5.3.6.  I have a point light that is simulating sunlight from a window.  It looks great, except the floor reflects a bright white circle.  I want the floor to reflect other lights in the room, just not this one.  Is this possible?


texts:
Given a view frustum and a sphere, how do I exactly determine whether or not the sphere  intersects the frustum? The typical way of checking a sphere against a frustum finds the signed distance of the sphere center from each frustum plane, but this isn't an exact test and will sometimes fail:

One method is to split the frustum geometry into triangles and test each triangle against the sphere for an intersection but this is slow.

Can SAT be used with a sphere? Are there any other faster methods?


texts: How do I determine if a triangle is visible in my view frustum?

texts:
I need a fast way to determine if a triangle is visible from a perspective projection view frustum. I am not looking to use an approximation with AABBs or bounding spheres, but need to accurately check an actual triangle against the frustum.

What do I need to do to test whether or not a triangle is completely outside the view frustum volume?

Edit: The nature of my question changed after discussing the actual problem I was trying to solve. I'm not too sure what to do here; do I accept answers based on the original question, or ones that address the actual problem? I'm also writing the original problem here for reference:

I'm trying to put together a 3d scene where I can get the visible longitude and latitude extents given an Earth sphere (centered at 0,0,0 in ECEF coordinates) and a normal perspective projection camera frustum. I then plan to load assets based on the lon/lat extents returned.

I couldn't figure out how to get extents given a view frustum analytically, so I tried to create a mesh based representation of the Earth at various LODs. I wanted to cull the triangles from this mesh against the view frustum which would leave a bunch of quads I could derive lon/lat extents from. Culling using vertices or bounding boxes wasn't appropriate at lower LODs where the mesh faces were much larger, which is why I needed to test the triangles themselves.

Seth's answer below seems like a better solution than generating meshes and culling them.


texts: Rotate Rigidbody to face away from camera with AddTorque

texts:
I have a camera that rotates around an object with "Look At" .

I want the object to rotate to face the direction the camera is pointing (Camera.main.transform.forward) using AddTorque, but I can't understand how.

I tried to create a rotation in which the more the object's forward vector rotates towards the camera, the more it should slow down the rotation until it stops. But it only works in sections, when I use the rotation of the camera the object rotates and then stops, as if it detects only one part of the rotation, while the other is a blind spot.

What equation can I use to rotate the object well?

var currentR = rb.rotation.y;
var targetR = Camera.main.transform.rotation.y;
rb.AddTorque(transform.up * 1000f * (targetR - currentR));

@DMGregory♦
I put your script as it is in a separate new script on a new object, equipped with a rigidbody.
I post the script how I entered it. At "targetOrientation" I gave the value of "Quaternion.LookRotation (Camera.main.transform.forward);" because I want the object to follow the direction of that camera.
The result is that all the axes of the rigidbody are influenced by the rotation (if I lift the camera the object turns towards the ground, etc.), and above all that the rotation works even if I block the axes with Freeze Rotation, and with this script the object is no longer affected by external forces.

public class rotation : MonoBehaviour
{
    private Rigidbody rb;
    public Transform direction;
    // Start is called before the first frame update
    void Start()
    {
      rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {

     Quaternion targetOrientation = Quaternion.LookRotation(Camera.main.transform.forward);
    Quaternion rotationChange = targetOrientation * Quaternion.Inverse(rb.rotation);

    rotationChange.ToAngleAxis(out float angle, out Vector3 axis);
    if (angle > 180f)
        angle -= 360f;

    if (Mathf.Approximately(angle, 0)) {
        rb.angularVelocity = Vector3.zero;
        return;
    }

    angle *= Mathf.Deg2Rad;

    var targetAngularVelocity = axis * angle / Time.deltaTime;

    float catchUp = 1.0f;
    targetAngularVelocity *= catchUp;

    rb.AddTorque(targetAngularVelocity - rb.angularVelocity, ForceMode.VelocityChange);

     }
    }

I set a command [if (Input.GetKeyDown (KeyCode.T)) rb.AddTorque (transform.up * 5500f, ForceMode.Impulse);] to rotate the object with an impulse and this does not work when your rotation script is active.
I also place a video where you see the object before activating the rotation script, and after it is active, to see how it does not react to the impulse with T, and how it rotates reacting on all rotation axes, while I want only that the rigidbody only rotates its Y-axis of rotation, in the direction of the camera (as a person does when turning in one direction). In the video The axes of rotation X and Z are on freeze (otherwise without fixed the rotation the object falls moving).
I also put a video of the desired effect taken from a game so as to explain me better.

My video
desired rotation


texts: Networking in a strategy, city management game

texts:
I'm developing a city management mobile game with its' share of multiplayer elements (leaderboards, achievements, social interactions). It's built using Unity and GameSparks as a backend. I'm a little bit confused on how I should be implementing the networking.

At the end of every in-game month, the game should go through every business building, calculate the revenue (each building generates different amounts of money depending on the number of workers), then add this value to the player's funds. These funds can then be used to continue building more businesses and houses, which increase the population.

I have to save the states for the city (buildings, population, etc) and player (funds, premium currency, etc) in the cloud.

I'm afraid people will exploit the game (due to the leaderboards) if I entrust data with the client, and I feel it would be best to keep the system deterministic, but I'm not completely sure I'm doing the right thing. How would you solve the problem?


texts:
I have a list of .FBX object.When I drag that .FBX into scene its corresponding inspector Animation component(fig 1) appears but when I drag some other .FBX object into the scene the Animator component(fig 2) is getting added to the scene.Please see the image attached

Issues Found :
1)fig (1) - When we click on the object and write code to display animation

void OnMouseEnter()
{
 animation.Play("DropBothFork01");
}

The above code is working
But if we consider fig(2) the code is not working even though adding a animation component.

What will be the issue?Why for each .fbx object when drag into scene the animation and animator component varries.Could you please help me out solving it.


texts: Attribute ownership in Entity Component systems

texts:
How do you typically handle data ownership in these systems?

Right now I just have a map that maps type(std::string or hashed int)->void* where outside sources can add attributes via a simple AddAttribute method.

Right now I'm having the problem of where and how to delete some of that data, since some of it is added via outside sources (e.g. reference to another entity) and some of it is legitimate data of the entity that contains it (e.g. health attribute).

The most obvious solution would be to simply use shared pointers, but somehow I'm worried that their overhead will become noticeable when I have a lot of entities (see https://stackoverflow.com/questions/3628081/shared-ptr-horrible-speed).

Another solution that I could come up with was to first use two distinct methods: "AddAttributeExternal" and "AddAttributeInternal" (or something similar, naming is irrelevant) where the attribute would only delete data that was added via the second. But I would like to avoid this since it introduces duplicate code and can probably be error prone when you introduce a lot of changing data.

Are there better/more optimized solutions or do I need to change the way I think about entity data altogether?


texts: Is it wrong to transmit information about a user's machine to my own servers without informing the user?

texts:
Let's say I ship a game on multiple platforms. My game code detects a few trivialities about the underlying system, like the local settings, the "country," the OS, the kind of graphic cards, etc.

Let's say I ship the game with code inside it that will send this information to a master server where I collect and manage all this data for building charts and such.

In a multiplayer game, it looks pretty reasonable to do this, since connections to that server are totally justified. Still, in a singleplayer game, it may look suspicious if you are informed about this operation.

Is it just wrong to embed this kind of data gathering system in a game? Do you think it absolutely should have a previous authorization from the user before doing any collection and transmission?

If users start to decline that "agreement," I can't really enforce 100% meaningful data. Thoughts?


texts: How do I access the "product name" in Unity 4?

texts:
I would like to access my app name in a Unity C# script; I've found PlayerSettings.productName, however it requires UnityEditor, which is only available in the editor.

So, in a normal application, how am I supposed to access its name, as it appears in the "product name" field of the player settings?

It must be cross-platform
retrieving the executable name (or directory) does not count
duplicating data does not count (obviously I can create a const with the same name, the whole point of this question is to avoid doing that)

(since the goal is to avoid duplicating data, backwards techniques such as having a const, and using that const to update PlayerSettings.productName is ok, as long as they require no extra step, i.e. they can be made to "run" automatically at compile time)


texts: Why do I need a local server for HTML5 game development?

texts:
I'm new to HTML5 game development. I'm trying to make something using Pixi.js, but when I tried to view it in a browser, I saw a blank page. According to the tutorial I'm following, I need to set up a local server. I'm not sure why I'd need to do that, though.

Could you please tell me why I would need a local server to run HTML files on my browser?


texts:
According to the "High Level API" documentation, unless I misread something, a Host "just" runs both as a Server and as a Client, so much that it would require no special support, i.e. it should run out of the box.

When the Server and Client are in separate processes, both work correctly. When a host acts as both the server and client, this is not the case.

When OnServerReady gets called on the Host, the NetworkConnection conn parameter has .hostId==-1, and if I try to call on NetworkServer.AddPlayerForConnection I'll get a warning and an error.

ClientScene::InternalAddPlayer: playerControllerId higher than expected: 0
UnityEngine.Networking.NetworkServer:AddPlayerForConnection(NetworkConnection, GameObject, Int16)
[...]

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Networking.ClientScene.InternalAddPlayer (UnityEngine.Networking.NetworkIdentity view, Int16 playerControllerId) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Runtime/ClientScene.cs:90)
[...]

If I refrain from calling AddPlayerForConnection, then I'll encounter a warning (and no result) as soon as the Host calls a Command:

Trying to send command for non-local player.
UnityEngine.Networking.NetworkBehaviour:SendCommandInternal(NetworkWriter, Int32, String)
[...]

In fact, isLocalPlayer is false.

Am I doing something wrong, is the documentation wrong, or is this a bug?

As requested, some piece of code:

public override void OnServerReady (NetworkConnection conn)
{
    base.OnServerReady(conn);

    Transform spawnPoint = FindObjectOfType<SpawnPoints>().getNextSpawnLocation();

    GameObject controllerGO = instancedElements.SpawnObjectFree(playerPrefab,spawnPoint); // this is basically an Instantiate
    GameObject playerGO = instancedElements.SpawnObjectFree(playerCreaturePrefab,spawnPoint);
    [...]
    NetworkServer.AddPlayerForConnection(conn,controllerGO,0);
    NetworkServer.Spawn(playerGO);
    [...]
}

(I've trimmed it down to remove the non-relevant parts)


texts: "Quad" background showing on OpenGl ES 1.0/1.1 Sprites

texts:
I modeled my sprite drawing on Grid.java and GLSprite.java from SpriteMethodTest,
using 2D OpenGl ES 1.0/1.1 on Android, but the "quad" sprite background shows when two
sprites overlap each other.  I'm not using double buffering though, in onDrawFrame()
I just do a
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

and the code in onSurfaceCreated() and onSurfaceChanged() and anywhere else
is pretty much identical.

My texture images are single layer .png with a transparent background and are
"even" sized.  And all the bitmap texture loading gl code is the same.
I compared my images with the ones from SpriteMethodTest, in Gimp, and they
appear to have the same properties.

The display area is black and when the sprites overlap, the "quad"
the texture is "on" is like a black square when it goes over another sprite.

What should I be looking for to try to fix it so that only the texture image is
visible?

Thanks!


texts: Movement and rotation of bodies in top down game

texts:
We are developing a 2D top down game with libgdx using the included box2d as physics engine.

We don't want our bodies to accelerate but to instantly move with the wanted velocity.
The bodies are moved like this, which works perfectly for our purpose:

Vector2 currentVelocity = body.getLinearVelocity();
Vector2 targetVelocity = velocity.velocityApplyVector.cpy();
targetVelocity.sub(currentVelocity);

targetVelocity.scl(body.getMass());

body.applyLinearImpulse(targetVelocity, body.getWorldCenter(), true);

The problem now is, that we also want the bodies to instantly rotate to the direction they are facing. The direction of the player is determined by the mouse position, so it is possible that the body is moving in another direction than it is facing. I tried to accomplish it like this:

float bodyAngle = body.getAngle() * MathUtils.radDeg;
float totalRotation = (inputRotation - bodyAngle) % 360;
if(Math.abs(totalRotation) > 1) {
    if ( totalRotation < -180) totalRotation += 360;
    if ( totalRotation >  180) totalRotation -= 360;
    float impulse = body.getInertia() * totalRotation;
    body.applyTorque(impulse, true);
}

This causes the body to rotate in the wanted direction but it needs multiple frames until it totally reaches the wanted angle.

The body mass is set to 70 and the angular damping to 8 (I tried some values for the damping and 8 was the best value for my cause, but that's, of course, not a final solution...).

I guess I have to somehow increase the needed impulse depending on the body mass and the angular damping (we want to be able to change it) but I can't figure out how to get the values right. I don't want to use setTransform since it totally destroys the physically correct behaviour of the bodies. How can I calculate the needed values? Is there any better way to solve my problem?


texts: How to avoid hard coding in game engines

texts:
My question isn't a coding question; it applies to all of game engine design in general.

How do you avoid hard coding?

This question is a lot deeper than it seems. Say, if you want to run a game that loads the files necessary for operation, how do you avoid saying something like load specificfile.wad in the engine's code? Also, when the file is loaded, how do you avoid saying load aspecificmap in specificfile.wad?

This question applies to pretty much all of engine design, and as little as possible of the engine should be hard coded. What is the best way to achieve that?


texts:
I currently am hiding objects that are not in the frustums view.
However, some objects are still being rendered that are in the frustums view, but are hidden. My goal is to not render objects that won't be seen at all rather than not render objects that are in the POV but are hidden.

Let me better explain.

There are three boxes, Box A, Box B, and Box C.
They are all aligned in the x axis, However, Box C has a greater y value than the rest of the boxes. Well if I'm looking straight towards Box C, I will only see Box C. But Box A and Box B are still being rendered.

I want to know if there is a method that I can use to not render objects that are hidden behind other objects.

Thanks in advanced,
Jedi.


texts:
So I am trying to do something like KSP, where I have a ground to orbit Level of Detail with the planets. And from theirBuilding a new Universe Video I know they are using scaled space, and local space, where (as i assume) The whole planet is divided in smaller quads. This is all fine but from my understanding They are all still in the same unity scene and rendered( if they’re not invisible( isn’t that automatically decided by the cpu/gpu?)). But now to my question. Even if such a Quad just has 16x16 Vertices, it’s still up thousand if not millions of units away from the scene origin and you and the camera(I know there are two cameras for near and far) Wouldn’t this quad produce a lot of lag and be really inefficient? Or is this not a problem for unity. Generally how far can I put things in unity?

Please also note that I know about the the trick where they move everything back to the origin if the ship passes 6000 units, to reduce the jittering.


texts: Downsides of using this integration formula for movement?

texts:
So I read that Gaffron integration basics tutorial and noticed how the Euler integration method gives a small error over time. I implemented the RK4 and noticed that with constant acceleration, I could simplify the formula. Over the course of an hour with some use of wolframalpha, I noticed that the formula eventually just simplifies down to just this:

float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

Position += (0.5f * Acceleration * dt + Velocity) * dt;
Velocity += Acceleration * dt;

I ran it through a console and sure enough, it gives the proper values for each timestep and the correct final value.

Will this formula always yield perfectly accurate answers? My acceleration will always be constant. Is there a name for this formula?


texts: Best strategy on VAO and texture coordinates for voxel rendering?

texts:
I'm working on a game that has to render a large amount of cubes (voxels) with OpenGL. All cubes have the same geometry (so I can re-use the vertex position VBO) and a single sprite sheet texture is used for all of them. This means the texture coordinates will have to vary for the cubes, depending on which sprite to use. All six sides of a cube will use the same sprite (in other words, the same texture coordinates).

Now, what is the best strategy to approach this with a modern OpenGL renderer?

I came up with two possibilities:

Create as many VAOs as there are cube sprites in the sprite sheet. Bind the same vertex position VBO to all of them, but a different texture coordinate VBO (according to what sprite / part of the texture to show). In my specific case, this would make for about 600 different texture coordinate VBOs and therefore 600 VAOs.
Create only one VAO. Set up the texture coordinate VBO in a generic way (e.g. 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0). In the rendering loop, send the actual texture coordinates (only 4 values) as uniform variable to the shaders. In the shader, the generic texture coordinates can be used to figure out which two of the four values from the uniform should be used.

Are there other possibilities that I'm missing? What is best regarding performance?


texts: intellectual property and non disclosure agreements on artwork

texts:
I am developing a game and would like to work with an artist. I am interested to know what other developers have done with regards to creating characters.  How does one draft up agreements that might be fair to both parties?

What I think might be good is: give the artist proper attribution and the right to display the work in portfolio, and agreement to pay the commission fee for the work, but let the game designer (the commissioner of the art) own the character and can do what he/she wants with the character in the future, including choose another artist if desired.

Just wondering how other people might have done it.


texts:
I have a strange issue in which the characters boundaries work fine, however are placed at four seemingly random edges outside of the game view as a result of (I'm assuming) my player boundaries script.  The player actually stopping at the edges is working fine, the issue is just with the placement of those boundaries.  I'm following a tutorial, and the code is pretty much just copy/pasted, so I'm not sure what's going wrong.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PSBoundariesOrthographic : MonoBehaviour {
    public Camera MainCamera;
    private Vector2 screenBounds;
    private float objectWidth;
    private float objectHeight;

    // Use this for initialization
    void Start () {
        screenBounds = MainCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, MainCamera.transform.position.z));
        objectWidth = transform.GetComponent<SpriteRenderer>().bounds.extents.x; //extents = size of width / 2
        objectHeight = transform.GetComponent<SpriteRenderer>().bounds.extents.y; //extents = size of height / 2
    }

    // Update is called once per frame
    void LateUpdate(){
        Vector3 viewPos = transform.position;
        viewPos.x = Mathf.Clamp(viewPos.x, screenBounds.x * -1 + objectWidth, screenBounds.x - objectWidth);
        viewPos.y = Mathf.Clamp(viewPos.y, screenBounds.y * -1 + objectHeight, screenBounds.y - objectHeight);
        transform.position = viewPos;
    }
}

Above is my boundaries script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class controlPlayer : MonoBehaviour
{
    public GameObject player;
    public float speed = 1000f;
    public GameObject left;

    bool _isLeftHeld;
    bool _isRightHeld;

    public void Update()
    {
        var movement = Input.GetAxis("Horizontal");

        // Ignore cases where neither/both left and right are held at once.
        if (_isRightHeld ^ _isLeftHeld)
        {
            // Override the movement input from the keyboard/joypad.
            if (_isRightHeld) movement = 1f;
            else movement = -1f;
        }

        transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * speed;
    }

    public void HoldRight(bool held)
    {
        _isRightHeld = held;
        _isLeftHeld = false;
    }

    public void HoldLeft(bool held)
    {
        _isLeftHeld = held;
        _isRightHeld = false;
    }
}

My player controller.  I should add that hold left and hold right are controlled by two buttons placed accordingly on the screen.


texts:
I'm looking into making a 2D motocross bike game with plausible physics.

It should look like this:

For a first try, I've created only the player (a motocross driver) and the map (consisting of only straight lines; no curves, to keep it simple).

How should collisions between the motocross bike and the track affect the bike's position and velocity? The bike should rotate if only one of the wheels touches the ground and speed up if the back wheel touches the ground. Pretty standard bike game stuff.

How do I achieve this behaviour?


texts:
I am messing around with Unity and the LPC Spritesheet Collection.

The LPC sprites are a set of artworks all of the same size and the same amount of animations. I can create animations for it no problem, when I do it manually.

My issue is: LPC has a lot of different character bodies (skin colors, different races), since they are of the same size and have the same animations in the same way, I was trying to create an AssetPostProcessor extension that would create the animations automatically when I import a LPC image into my project.

I am already able to slice the spritesheets correctly with this Script I found, and I can create and save the animation clips based on the spritesheets. The clips have the correct length and configuration, but the sprites for each frame seem to be empty! Take a look at the image below...

This is the piece of code that generates the animations from the sprite meta datas:

    for (int col = 0; col < m_ColCount; ++col)
    {
        SpriteMetaData meta = new SpriteMetaData();
        meta.rect = new Rect(col * LPC_SPRITE_SIZE, row * LPC_SPRITE_SIZE, LPC_SPRITE_SIZE, LPC_SPRITE_SIZE);

// I skipped some code for renaming and checking for empty sprite frames for brevity...

EditorCurveBinding spriteBinding = new EditorCurveBinding();
        spriteBinding.type = typeof(SpriteRenderer);
        spriteBinding.path = "";
        spriteBinding.propertyName = "m_Sprite";

    ObjectReferenceKeyframe[] spriteKeyFrames = new ObjectReferenceKeyframe[currentLoops.Count];
    for (int i = 0; i < currentLoops.Count; i++)
    {
        spriteKeyFrames[i] = new ObjectReferenceKeyframe();
        spriteKeyFrames[i].time = i;
        spriteKeyFrames[i].value = currentLoops[i];
    }

    AnimationClip clip = new AnimationClip();
    clip.name = animState.ToString();
    clip.frameRate = currentLoops.Count;

    AnimationUtility.SetObjectReferenceCurve(clip, spriteBinding, spriteKeyFrames);

    if(!changesToSave.ContainsKey("Assets/Sprites/" + clip.name + ".anim"))
        changesToSave.Add("Assets/Sprites/" + clip.name + ".anim", clip);

    Debug.Log("Added " + clip.name);
}
TextureImporter textureImporter = (TextureImporter)assetImporter;
textureImporter.spritesheet = metas.ToArray();

And I am saving the sprites in the OnPostProcessSprites callback like this:

Debug.Log("Sliced Sprites: " + sprites.Length);

foreach (var key in changesToSave.Keys)
{
    AssetDatabase.CreateAsset(changesToSave[key], key);
}

var textureImporter = (TextureImporter)assetImporter;
Debug.Log(textureImporter.spritesheet.Length);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();


texts:
This is my vertex shader, shown below.

#version 330 core

in vec3 a_position;
in vec4 a_colour;

// FOV = 70, near plane = 0.1, far plane = 1000
const mat4 u_projection = mat4(
    1.428148, 0.0, 0.0, 0.0,
    0.0, 1.428148, 0.0, 0.0,
    0.0, 0.0, -1.0001999, -0.20002,
    0.0, 0.0, -1.0, 0.0
);

//uniform mat4 u_projection;
//uniform mat4 u_view;
uniform mat4 u_transformation;

out vec4 v_colour;

void main() {

   gl_Position = u_projection * u_transformation * vec4(a_position, 1);
   v_colour = a_colour;
}

Whenever I take out u_projection, my square appears. When I add it back, the square is malformed.

The vertices of my square are as follows, aka the contents of a_position.

float[] vertices = {
    0, 0, 0.5f,
    0.5f, 0.5f, 0.5f,
    0, 0.5f, 0.5f,
    0, 0, 0.5f,
    0f, 0.5f, 0.5f,
    0, 0.5f, 0.5f
};

The position of the square is (0, 0, 0), the rotation is (0, 0, 0) and the scale is 1. These are computed into u_transformation and uploaded. This works perfectly.

If I change the -1.0001999 and the last 0 to 1 part to 1 then the square is not hidden.

void bindAttribute(int index, String name) {
    GL20.glBindAttribLocation(program, index, name);
}
bindAttribute(0, "a_position");
bindAttribute(1, "a_colour");


texts: How to fire a projectile in a certain direction with constant velocity (directX 9)

texts:
I am working on a top down 2d shooter.  I am trying to make the bullets go at a constant speed (in pixels) in the direction of the mouse.  I am having trouble doing this.  My bullets fire directly 45 degrees off where the mouse is.  I wrote this method which sets all the angles and rate of travel.
travelRate: Bullet speed in pixels per frame

targetX: target X coordinate in pixels

targetY: target Y coordinate in pixels

changeX: how far the bullet should go per frame along the X axis (in pixels)

changeY: how far the bullet should go per frame along the Y axis (in pixels)

ent:  The player/npc shooting the Projectile

I do not understand why my bullets are going at a 45 degree offset from the mouse.NOTE: I cut out some of the unimportant code from this method.

void Projectile::init(Entity * ent, int targX, int targY)
{
travelRate = 4;
setX(ent->getX());
setY(ent->getY());
targetX = targX;
targetY = targY;
float deltaY = getX()-targX;
float deltaX = getY()-targY;
float dLen = sqrt(deltaX*deltaX + deltaY*deltaY);
if (dLen == 0)
    dLen == 1;
deltaX /= dLen;
deltaY /= dLen;
float deg = rad * 180 / PI;
changeX = deltaX * travelRate;
changeY = -deltaY*travelRate;
}


texts: Trying to get Vertexshader to work Monogame 2D

texts:
If I don't use the vertex shader, it gives me white textures which is what the default color is. Once I add the vertex shader, the screen is black.

I figure it is something wrong with the Matrices I give the shader, but I am not sure.

    #if OPENGL
    #define SV_POSITION POSITION
    #define VS_SHADERMODEL vs_3_0
    #define PS_SHADERMODEL ps_3_0
#else
    #define VS_SHADERMODEL vs_4_0_level_9_1
    #define PS_SHADERMODEL ps_4_0_level_9_1
#endif

matrix WorldViewProjection;

struct VertexShaderInput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
    float2 texCoord : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
    float2 texCoord : TEXCOORD0;
};

VertexShaderOutput MainVS(in VertexShaderInput input)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Position = mul(input.Position, WorldViewProjection);
    output.Color = input.Color;

    return output;
}

float4 MainPS(VertexShaderOutput input) : COLOR
{
    return input.Color;
}

technique BasicColorDrawing
{
    pass P0
    {
        VertexShader = compile VS_SHADERMODEL MainVS();
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};

My projection matrix(The default that spritebatch uses).

projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) * Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, -1)

Setting my WorldViewProjection matrix.

negEffect.Parameters["WorldViewProjection"].SetValue(projection);

Only projection since I turned off my camera to make it easier to debug.

The drawing code.

GraphicsDevice.SetRenderTarget(renderTarget);
GraphicsDevice.Clear(Color.Black);
var debugMatrix = debugCamera.GetViewMatrix();

spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, negEffect);

spaceObjectManager.Draw(spriteBatch);
spaceEnemyManager.Draw(spriteBatch);
playerShip.projectileManager.Draw(spriteBatch);
playerShip.Draw(spriteBatch);

spriteBatch.End();

GraphicsDevice.SetRenderTarget(null);

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
spriteBatch.End();

physicsDebug.RenderDebugData(ref SimProjection, ref debugMatrix);

VertexShader off.

VertexShader on.

Thanks in advanced!


texts:
I've just ported over and updated a bunch of FBX model loading code I had that worked with Direct X 10 to try and make it work with Direct X 11. Since that time, the FBX SDK I was using has been updated.

In my old program I linked to the following lib:

fbxsdk-2012.2-mdd.lib

Now, clearly I can't link to this as I don't have 2012.2 on my system. So, my thinking would be simply changing 2012.2 to 2014.1, but this didn't work and lead to the following error:

error LNK1104: cannot open file 'fbxsdk-2014.1-mdd.lib'

So I tried to some googleing to see what the updated version of fbxsdk-2012.2-mdd.lib is. But I can't find anything. I tried taking out linking ot the 2014.1 lib but I get the following errors:

  Error 36  error LNK2019: unresolved external symbol "void __cdecl fbxsdk_2014_1::FbxAssert(char const *,char const *,unsigned int,char const *)" (?FbxAssert@fbxsdk_2014_1@@YAXPBD0I0@Z) referenced in function "public: int & __thiscall fbxsdk_2014_1::FbxArray::operatorconst " (??A?$FbxArray@H@fbxsdk_2014_1@@QBEAAHH@Z)

So, looking in the FBX sample directory I opened up the ViewScene sample to see what it lib it linked to and I see that it wanted the following:

libfbxsdk-md.lib

So I did the same. But, my program claims it cannot open the file. And I'm at a loss as to what to do next.

Has anyone successfully managed to load FBX models into a Directx 11 application using 2014.1? If so, what do I need to do to get the correct lib linked?


texts: How do i prevent IAP abuse using restoring purchases in an online game?

texts:
Lets say i have a mobile mmorpg (ios/android) where you can purchase premium currency using IAP's... how do i actually prevent the following case :

Player purchases premium currency
Server side checks if the purchase is valid, grants the user premium
currency
Player uses the premium currency to buy some items
Player restores his purchase on google play and gets his money back

Result : Player didnt spended money and still got what he wanted

As long as i know theres no option to prevent that case in google playstore or ios app store... Users can restore purchases within 48 hours after the purchase.

So what could i basically do to prevent this, aslong as i dont use 3rd party payment services like PayPal ?


texts: How to handle NPCs and other entities on moving objects like trains or planes

texts:
I was always wondering how trains or other moving platforms are implemented in games. For example: there a many games where you can walk on the back of a truck or on a train that starts to move. During this time you can freely walk around like you could on normal map. (I don't think about rail-shooter parts were you just fire a gun or sit still somewhere). Of course you could load a new map that just gives you the feeling of moving where actually the map is pure static, but that's not what I mean.

How does the game translates all the vehicle movements to the actual position of the entities that are on it? Especially AI, collision (you don't fall throu the platform due to some glitches) and smooth rendering (some games screw this up and you see the entities bouncing up and down).

If I would do this than I would probably use an own coordinate system for the platform and translate this into the "real" on. But I have no idea how this would look since you would have to store the "belonging" platform for every entitie and I think there's probably a better solution.

I think a good example is the transport system in World of Warcraft. The NPCs even have waypoints during flights and you can trade with them. It actually feels like on the ground.

I would really like to get some links with detailed explanations if there are any.


texts: How can I make this style of 2D "glowing" graphics?

texts:
I'm comfortable with the basics of building a 2d sprite based game in XNA, where all my objects are simply .png images that I move around.

What things do I need to learn next to be able to develop a 2d game that utilizes an art style similar to Super Laser Racer for example.

Other examples of this style would include Frozen Synapse, Geometry Wars, etc.

I would describe this style "2D abstract glowing geometry" or something like that.

I can see that a lot of the effects in these types of games are achieved via particle systems and also that maybe some things are still just sprites that were maybe drawn in a graphics editor to look all "glowing" etc.

But then the rest is possibly done by making draw calls to DirectX and implementing custom shaders, etc?

Is that right? I'm not really sure of what to learn next to be able to go in this direction or what questions to ask.


texts: How can I hide the collision layer in libGDX with TiledMap?

texts:
I'm making a 2D game with libGDX, and I'm using its TileMapRenderer to render my map which I have made in the map editor Tiled. In Tiled, I have a dedicated collision layer. However, I can't figure out how I'm supposed to hide it and its tiles in the game.

This is how a map is loaded:

TiledMap map = TiledLoader.createMap(Gdx.files.internal("maps/map.tmx"));
TileAtlas atlas = new TileAtlas(map, Gdx.files.internal("maps"));
tileMapRenderer = new TileMapRenderer(map, atlas, 32, 32);

Currently the collision tiles are rendered on top of everything else, as I see them in the map editor.


texts: Get the up vector of the camera in ARKit

texts:
I'm trying to get the four vectors that make up the boundaries of the frustum in ARKit, and the solution I came up with is as follows:

Find the field of view angles of the camera
Then find the direction and up vectors of the camera
Using these information, find the four vectors using cross products and rotations

This may be a sloppy way of doing it, however it is the best one I got so far.

I am able to get the FOV angles and the direction vector from the ARCamera.intrinsics and ARCamera.transform properties. However, I don't know how to get the up vector of the camera at this point.

Below is the piece of code I use to find the FOV angles and the direction vector:

func session(_ session: ARSession, didUpdate frame: ARFrame) {
  if xFovDegrees == nil || yFovDegrees == nil {
    let imageResolution = frame.camera.imageResolution
    let intrinsics = frame.camera.intrinsics
    xFovDegrees = 2 * atan(Float(imageResolution.width) / (2 * intrinsics[0,0])) * 180 / Float.pi
    yFovDegrees = 2 * atan(Float(imageResolution.height) / (2 * intrinsics[1,1])) * 180 / Float.pi
  }

  let cameraTransform = SCNMatrix4(frame.camera.transform)
  let cameraDirection = SCNVector3(-1 * cameraTransform.m31,
                                   -1 * cameraTransform.m32,
                                   -1 * cameraTransform.m33)
}

I am also open to suggestions for ways to find the the four vectors I'm trying to get.


texts: How can I orbit a camera about it's target point?

texts:
I'm drawing a scene where the camera freely moves about the universe.  The camera class keeps track of the view (or look at) point, the position of the camera, and the up vector.  These vectors/points are then passed into gluLookAt.

Pan and zoom are nearly trivial to implement.  However, I'm finding rotation about the look at point to be much more of an issue.  I want to write a function Camera.rotate that takes 2 angles, one that rotates up/down and one that rotates left/right along an imaginary sphere that is centered about the look at point.

Is there an easy way to do this?

I've (briefly) read about quaternions, but I wanted to see if there was an easier solution given the relatively simple construction of my scene.


texts: Confused why draw code is clearing, pico-8 api demo

texts:
In the API demo when they do the example of how to draw a colour pallette at the top of the screen:
I notice the commands don't work when used inside the draw function. When used inside of draw they showup for a second and disappear. removing the cls() allows them to stay, but I need cls included. What do i need to be doing to get the pallette to stay while using the following within the draw function?

function _draw()
       cls()
       rectfill(1,1,7,7,5)
       for i=0,10 do
          print(i,x,2,i)
          x = x + 6
       end
end


texts: How would you handle different level-types in an entity-component-system?

texts:
Im currently developing a game with the entity-component system of Ashley in Libgdx (Java).

In the game you would be able to walk on planets (2D not 3D), fly in the star system and traverse between systems. These are all different types of levels that all need to be handled and rendered differently.

So my question is, how would you differentiate between these types (for example in the renderer), should I add a case for every type in the renderer or split it up somehow?


texts:
I try to spawn one or two obstacle at the same time given the position rightpos, midpos, and leftpos but i keep getting the spawn position to only rightpos and midpos.

     void Start () {
     rightpos = new Vector2(2f,6f);
     midpos = new Vector2 (0f,6f);
     leftpos = new Vector2 (-2f, 6f);
 }

 // Update is called once per frame
 void Update () {
     if (spawn_activate == true) {
         number_of_spawn = Random.Range (1, 2);
         spawn_activate = false;
     }
     if (number_of_spawn > 0) {
         spawnposition = Random.Range (0, 2);
         if (spawnposition == 0) {
             Instantiate(obstacle,rightpos,Quaternion.identity);
         }
         if(spawnposition == 1) {
             Instantiate(obstacle,midpos,Quaternion.identity);
         }
         if(spawnposition == 2) {
             Instantiate(obstacle,leftpos,Quaternion.identity);
         }
         number_of_spawn -= 1;
     }
 }


texts: Will I lose the mesh if I delete the original prefab?

texts:
I'm working in Unity 5, and I currently have the following setup:

My project contains two prefabs which we'll call "Cube" and "CubeT". Cube was imported from an FBX file generated by Autodesk 3DS Max, and CubeT was created within Unity. I want to be able to modify Cube's mesh collider, but Unity will not allow me to do so. Therefore, I've thought about adding the mesh within Cube to CubeT and removing Cube. The thing is, I'm worried that I'll lose the mesh when I delete Cube, and subsequently lose the reference to it in CubeT.

If I reference Cube's mesh in CubeT and then remove Cube from the project by deleting the asset within Unity, what will happen? Will the needed mesh remain in the project or am I going to have to find another way?


texts:
I'm trying to spin up my own 3D vector graphics engine, so I'd like to do this without an existing library. And I don't seem to be able to find the math for the correct approach in rotating an object around its own axis.

I can definitely do x/y/z rotations around a chosen point with values pt.x pt.y and pt.z. But I am unsure of how to make them unique to the object's orientation, so they are always being expressed in relation to the monitor (not even the environment yet, just the screen).

So which mathematical concept am I supposed to be applying here?


texts: How can shears/reflections/enlargements be represented by 4x4 matrices?

texts:
I understand that 4x4 matrices can represent transformations on a 3d point (represented as x, y, z, w)

Eg, a translation is

[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[x y z 1]

where x, y and z are the amount to move the point along each axis.

I know how to represent translations, scaling and rotations but how are other transformations such as shears (with any invariant plane and shear factor), reflections (in any plane) and enlargements (with any center and any scale factor) represented?

The end goal is to have c++ functions to create a translation matrix.
Eg:

Matrix4x4.generateReflection(Vector3d planeNormal);
Matrix4x4.generateEnlargment(float centerX, float centerY,
                             float centerZ, float scaleFactor);

These would return an instance of a Matrix4x4 class with the elements set such that multiplying it by a point returns the sheared/reflected/enlarged point.


texts:
I'm new to writing games. I'm planning to write a 2D battle game which may require an physics engine. Suppose I've written one, but how can I combine it with the main routine of my game? Should I attach it directly to the graphics render routine or put it in an individual thread? I've spent much time looking for some common approach, but found nothing. So can you reveal some basics idea for me, a newbie? Thanks!

P.S. There're many other problems I have to deal with if I choose to start a separate thread for the physics engine, for example, the lock problem, while from my intuition, I guess I'd better separate the render and the physics engine.


texts: Does Unity store temporary autosaves for scripts? If not, how do I avoid data corruption

texts: My PC lost power in the midst of a save(twice in a row) and I've lost my scene setup as well as a script(its contents actually). I would like to know if there are any fail-safes for saving files. If not, how would I prevent future data loss/corruption.


texts:
I am trying to break a tileset image from my content folder into individual tiles during program. What I would like to have happen is that i can fill a list (of thing) with each possible tile so I can reference it by calling list(x).

However, in XNA I can't access the bitmap class and I can't Import it either (I might be doing it wrong) nor can I create a texture2d since where this is being called at comes from a different class file.

How do I split apart the tileset image into the separate tiles that I need and store them into a list?


texts: Unity3D Directional lights vs Draw calls

texts:
I need 2 light sources looking at a different direction as per my design.
This means, I cannot flag one of them as 'not-important'!
I found that because I'm using 2 directional lights, drawcalls are aggrevated.
Can somebody provide me a direction.

With one DL: 7 draw calls. With 2 it goes to 60 odd.
It is the same case if I switch them vice versa.


texts: Why do console versions of multiplayer games support fewer players than PC versions?

texts:
source
http://answers.yahoo.com/question/index?qid=20111205162848AAb1sl9

  64 Players on P.C ( 32vs32)

  & bigger maps with more vehicles & buildings.

  24 on Consoles ( 12vs12)   ( It was planned to have a 32 player
  limit, but was later reduced to 24).

Why does the console version have a maximum of 24 players? Is it hardware related?

One of the reason was that players can host games themselves. If thats true its very sad that you cannot play 32x32, because one or two guys want to host games.


texts: Parenting a child object to parent in Unity

texts:
I am making an 3d Tennis game in Unity 5.0. I have made 3d model of the Tennis player in Makehuman and have successfully imported it to Blender and Unity.

I want to add an tennis racket in the hand on my Makehuman model. So what should the strategy be?

Should I add the tennis racket to the Makehuman character in Blender as the child of the Makehuman model and then animating it or is there a simple way to do that in Unity in the game.


texts:
I am and have been quite interested in programming games for quite a while now, however an interesting question I've thought about lately is what do I want to specialize in?

After doing some research I found that game developers/programmers could specialize their skills in quite a few fields such as:

AI
Interface design
Game engine development

There are even some who focus on optimizing network code in the case of online multiplayer games. So I guess my question would be, what other aspects of games programming exist that I could focus on? What would be the ones that are more valued and would increase my chances of being employed in a well paying company?


texts: Given its direction, and another vector that begins at the same point, how can I find the magnitude of that vector using only vector math?

texts:
I've solved this using the law of sines, but I was wondering if there's a way to do this with just vector math.
Here's a diagram that will hopefully help illustrate what I'm trying to do:

Given vector a and the direction of b, how can I find the magnitude of b? Both vectors share a common origin point. The white line is just supposed to show that both vectors will extend to the same position on either the x or y axis.


texts: How to add custom control shapes to a rig in Maya

texts:
I find most Maya animation videos has these circle lines to control character part rotation:

Why does my imported fbx not have these circle lines?


texts: On cocos2d, what is better: one monolithic game cycle or many scheduled selectors?

texts:
I am building a simple tower defense game, and I have to take a decision between two(or more, feel free to suggest other ways) to do the game cycle.

Option 1: Monolithic game cycle:

I could have a global scheduled selector that calls update for every sprite/object/logic thing that I need to calculate.

I could achieve this by having a singelton Game class that has a mutable array of objects and then on the Scene(or that singelton) I could have a setup with:

[self schedule: @selector(gameCycle:) interval:0.1];

And then on that gameCycle do something like:

-(void) gameCicle: (ccTime)dt {
    for(Entity* e in [[Game sharedGame] entities]){
        [e gameCicle];
    }
}

Second option: Each object could create its own selector @ init.
This is almost the same, but instead of a singleton, every time that i create a object I could create a new scheduled selector as such:

-(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect {
    if( (self=[super initWithTexture:texture rect:rect])) {
        [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
            [self schedule: @selector(gameCycle:) interval:0.1];
    }
    return self;
}

Now I don't know what is better(or if there is a very big difference in performance). What is the usual/best approach for cocos2d?


texts: Manipulating an animation towards a target object (ie. The hand and arm lean towards the target)

texts:
I am trying to make a boxing game just for fun (I dont expect the end product to be anything decent lol) . I have my boxers in the ring and they are animated quite well so far, with Idle, and punch Left and Right. They also rotate so they are always looking at each other.

What I want to do is give the punch some aim towards the head. I will give the punch a set amount which it can move from the standard animation and move the hand bone in the direction of the targets head object. But I don't know how to do this :S

So far i have used dragged the 3 animation files into Mecanim and coded it to do the animations when a button is pressed.

Is there a way to manipulate the animation in this way? (ie. actually make the arm reach towards the target object )


texts: As an artist, how do I go about gaining "experience", and how do employers define it?

texts:
I'm a freelance 3D artist, and recently I've been looking into getting a full-time job as a character/environment artist (character prefered) and up until now I've only been doing unpaid commissions with two small paid jobs along with my current paid commission, a cinematic for a modding company.

My issue is this: nearly every game artist job, no matter how large or small the studio is, requires at least two years experience in the field before most will even consider looking at your portfolio. Only recently have I gotten out of college, and I'd like to think that I'm extremely competent and self-motivated, but it's impossible to find any serious companies who won't consider me a risk for having such a limited amount of real-world experience. I've been doing free commissions to expand my portfolio for nearly 3 years to the date, but I'm fairly certain this doesn't qualify as "experience" in the eyes of employers.

So the question stands. How do employers define experience, and how do I go about gaining that 2 years of required paid experience, or do employers care once they see your portfolio?

Any help would be greatly appreciated.


texts: Check whether a game object is inside the boundary

texts:
I'm developing a small children game similar to Paperama. Here the player can scale rotate and move the object anywhere in the screen and the player should fit it in the boundary. I'm okay with everything (scale, move, rotate etc..) but I couldn't think of a way how to measure the percentage where the target object is inside the boundary object. Here is a graphical representation of what I want to achieve.

I tried comparing vectors and positions but it's so complex and inefficient for symmetrical objects where multiple positions are acceptable to fill the void.

Thanks in advance! :)


texts:
Currently I have this to rotate my 3D model that rotates on it's local axis independent from the world's axis:

// Rotate model with Right Thumbstick
modelRotation -= pController.ThumbSticks.Right.X * mRotSpeed; // float value

What I'm trying to do is rotate the model using quaternion and not by a matrix.

I've searched for tutorials, but have found none that explains thoroughly on how to achieve this. Does anyone know how to I can use quaternions to rotate my model or a complete tutorial?


texts: Is there a way to earn money from non-mobile HTML5 game?

texts:
I'm just a hobbyist, who has some ideas, that would not fit on a mobile screen. I have searched for some method, to make a bit of money from them, but I've found just for mobile-optimized games.

So the question is: is there any way to earn some money from these games, too?


texts: Python: I have a python statement which should work but it doesn't

texts:
The error in the picture is highlighted in red.

So, I have used this code on another computer and it worked, why wont it work now? I may have made a really small and stupid error and if I have I'm sorry for wasting your time but, it should work. By the way, this is only made to run in the python shell and it is not supposed to have an graphics except for the text.

For a bit of context, this is being used at the beginning of a game I am creating and it is used to determine the difficulty level.

If this isn't supposed to work at all but there is an alternative, I would appreciate the help.

All help, comments and answers are appreciated.


texts: OpenGL align grid like glOrtho but with gluPerspective?

texts: Using gluPerspective makes OpenGL's grid really messy and rather hard to use especially when trying to do mouse input. The grid that perspective uses is completely messed up compared to the grid you get with the mouse. When using glOrtho the grid is fixed to the mouse grid, but then you can only do 2D work, how would I set up perspective to get the same results as if I were using glOrtho?