texts: How to nest one Unity project into another?

texts:
I'm creating an AI course in Unity. With regard to my question, there are two important properties of the course:

Each tutorial is a separate Unity project that can be loaded up, allowing the student to start anywhere in the course and have a project that mirrors the project covered in the video they're watching.
Each tutorial builds off of previous tutorials. For example, tutorial one is just the base world provided with the course. Tutorial 5 includes all the code and assets introduced in tutorials 1-4, from the base world up.

My question is, how do I manage the nesting of Unity projects, without a lot of manual updating and copying?

Say, for example, when I'm creating the content for tutorial 5, I find a bug in the code created in tutorial 2. I don't want to have to update tutorials 2,3,4 and 5. I want to fix the bug in tutorial 2 and have it propagate through all the future tutorials that utilize that code or asset.

Essentially, each tutorial is a milestone on the way to the completed project. The completed project is the sum of all the tutorials and will contain all of the code, assets, prefabs, etc.

You can think of this like a dependency tree. Tutorial 5 depends on the code and assets of tutorial 4, which depends on the code and assets of tutorial 3 and so on. If this were a Visual Studio project, I'd create a new project and configure the dependencies under one solution.

In this example, the lines represent files that are identical to each other. Changes to the file in its origin project should update the file in subsequent projects. Ideally, a change to the file in any project would update all the others, but it's not a required feature

I am, of course, using source control as well. So there may be a trick or two I can utilize there, but I'm not sure.

Some things I don't think will work:

Exporting code as a DLL, to be used in the next project. I don't think this will work because I don't want the student to have to do this with their own project. That means a student going through the course one tutorial at a time would have a different code structure than the student who started part way through.
Creating Unity packages. This would maintain the code, assets and prefabs, but (as far as I can tell) would require me to re-export and re-import packages for each project subsequent the changed project. But I believe this has the most potential if there's a way to automate the process.

Nesting projects like this would also be useful in other situations. Like a developer who's built up a core project they want to start all of their projects from. They could have 5 game that all have the same "base project" and each of the 5 game would benefit from bug fixes or feature adds that go into the base project, meaning the change is only made once.


texts:
Developing on the XNA framework for Xbox, I have different 2D image resources being used depending on the level. At the end of a level, I'd like to leave as much loaded as is reasonable, so that the next time a level needs that resource, it's already loaded. However, there will be a great many resources, so I'm assuming that it's a poor idea to leave everything loaded always, simply because memory is limited. Is there a good way to know how much to reasonably unload to keep things running smoothly?

My idea: If the .net garbage collector supported soft references (like the JVM), I could change references to any resources not being explicitly used to soft references, and change them back or reload when they're needed again. That way the garbage collector, who knows the state of memory much better than I, can intelligently drop references as needed when loading new content. In other words, a simple cache. This soft reference construct doesn't exist in C#, however; is there an equivalent or some better way to handle this?


texts: How to make two keys pressed to make an action?

texts:
Hey i am beginner gamedev. I couldn't find answer to this or I am bad articulating my problem. But really would like an answer to this. How can i make function to press two keys like A and D at the same time to make a jump animation if A and D are already taken separately to A = walk left and D = to walk right? Without them overlapping.
func _input(event):

if event.is_action_pressed("left") && event.is_action_pressed("right"):
    $DancerSprite.play("bluedouble")

if event.is_action_pressed("left"):
    $DancerSprite.play("blueleft")
    return

elif event.is_action_pressed("right"):
    $DancerSprite.play("blueright")
    return


texts:
I'm not sure if "game state" is the correct term, as my searching shows me a lot of results that are not relevant to my question. When I say "game state", I'm talking about the internal state of the game being played: what units are spawned, where they are located and headed, what players are playing, what their current scores are, etc. Everything that would get wiped out if you were to start a "new game".

That said...

I'm curious how other people or other games handle the issues of client and servers appearing to need access to more than one copy of the game state.

For example, the client's job is to accept game state updates from the server, and render them. However, the server updates are usually much slower than the client render speed, so the client needs two copies of the state information in order to interpolate between the two and make everything appear to be moving smoothly. I'm not sure how you would accomplish this without having the client hold two copies of the game state, copying the current to the previous whenever the server sends an update.

Likewise, the server needs to make decisions on the current game state, and apply changes. However, if it only has one copy of the game state, then any changes it has already made will influence future decisions. If two players shoot at each other at the same time, and the server processes one shot before the other and writes the result to the same game state, it'll see the second player as now being dead and unable to shoot. If it had two different game states, "current" and "next", any new changes (such as player death) would be written to the "next" state, and since they are both still alive in the "current" state, each shot would get processed and both players would end up dead, as expected.

However, having multiple game states creates a lot of other problems:

Each copy of the game state could be very large, with many players playing, and hundreds or thousands of units moving around the game world. This would be a lot of data to be copying around just to keep multiple game states synchronized.
While having two separate game states fixes the server problem of two entities killing each other at the same time, it presents new problems when an entity is newly-spawned. You might spawn an object into the world, and then want to immediately have it perform an action, or have other entities start to interact with it. Problem is, that new entity doesn't exist in the "current" game state, it only exists in the "next" game state. The server would have to wait until the next cycle, when the "next" state became the new "current" state, before the new entity was available for interaction.

I'm leaning towards just having a single state for the server, just for simplicity, but I don't see how to avoid keeping two copies for the client. How do other games handle this?


texts:
I am coming back again into hobby game development after about 6 months away. I'm just trying to learn some kind of basic things again. I'm at the very start of making a very simple boxing management simulator. Later, I will be trying to re-learn using databases and might ask for more help.

But for now, I'm making a Boxer class which will hold all the data on each boxer (eg. Name, height, number of wins, punch power etc etc). I've used private variables for those and then have made my own methods for each variable called Getxyz().

I have seen people doing things like 'public int xyz { Get(); }' but i dont understand how that would work.

Is the way I'm doing ok (it does seem long-winded to me) or should I investigate these Getter Setters some more? Here's what I am doing right now:

public class Boxer : MonoBehaviour {
// generic boxer details:
int id;
string nameA, nameB;
int weight;
int height;
float age;
float reach;
// career info:
int wins, loses, draws, winsByKO;
// boxing attributes/stats:
float power, speed, agility, koPunch, stamina, toughness;

public int GetId()
{
    return id;
}
public string GetNameA()
{
    return nameA;
}
public string GetNameB()
{
    return nameB;
}

}


texts: Push data in unity Player without Requesting

texts:
I have a unity3d Player where I need some data from the server. The server code is written in python while on client side is C#.

Now I am searching a way that server directly post/push data to my unity player. IMO! it is not possible to push data to unity player without requesting the server using WWW class. My question is can python post data to my client unity player? with something like

response = requests.post(client_url, data = request_data, headers = headers)

I want to do this because i want to avoid repetitive calls to server which is not an efficient way.


texts: Transformation problems with hardware instancing in DirectX 11

texts:
I'm getting some wonky geometry in my application when trying to use instancing. I'm not sure if I'm doing the mapping of my per instance data wrong. This is how my mapping looks like:

XMMATRIX scale          = XMMatrixScaling( 1.0f, 1.0f, 1.0f );
XMMATRIX rotation       = XMMatrixRotationY( mRotation * 10.0f );
XMMATRIX translation    = XMMatrixTranslation( 0.0f, 0.0f, 0.0f );

XMMATRIX finalTransform = scale * rotation * translation;

XMFLOAT4X4 world;

XMStoreFloat4x4( &world, XMMatrixTranspose( finalTransform ) );
mBox->PerInstanceData( world );

D3D11_MAPPED_SUBRESOURCE mappedResource;
hr = mDeviceContext->Map( mPerInstanceBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource );

if( SUCCEEDED( hr ) )
{
    memcpy( mappedResource.pData, &mBox->PerInstanceData(), sizeof(PerInstanceData) );
    mDeviceContext->Unmap( mPerInstanceBuffer, 0 );
}

I've constructed my input layout like this:

D3D11_INPUT_ELEMENT_DESC inputDescInstanced[] = {
            { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
            { "NORMAL",   0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
            { "WORLD",    0, DXGI_FORMAT_R32G32B32_FLOAT, 1,  0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
            { "WORLD",    1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
            { "WORLD",    2, DXGI_FORMAT_R32G32B32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
            { "WORLD",    3, DXGI_FORMAT_R32G32B32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
            { "COLOR",    0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 64, D3D11_INPUT_PER_INSTANCE_DATA, 1 }
        };

And this is how a part of my shader looks like:

struct VertexIn
{
    float3              position    : POSITION;
    float3              normal      : NORMAL;

    // Instanced data
    row_major float4x4  world       : WORLD;
    float4              color       : COLOR;
    uint                instanceID  : SV_InstanceID;
};

PixelIn VS( VertexIn input )
{
    PixelIn output = (PixelIn)0;

    output.position = mul( float4( input.position, 1.0f ), input.world );
    output.position = mul( output.position, view );
    output.position = mul( output.position, proj );

    output.normal   = normalize( mul( input.normal, (float3x3)input.world ) );
    output.color    = input.color;

    return output;
}

The final output of the cube looks like this:

Any suggestions? Thank you!


texts: OpenGL / Soil Image Loading Difficulties

texts:
The Problem

I am attempting to load and display an image in OpenGL using the SOIL library.  I originally started with lodePNG but I had difficulties getting the image to display so I assumed it was just a library issue and decided to switch to SOIL, however, as I am having the same issue now I believe it must be something that I am doing wrong somewhere in my own code.

So, the exact issue is that I seem to be able to load a texture correctly: the width and height attributes get set to the appropriate value, and if I just dump the data it loads to console it seems to have actually grabbed the appropriate data (Screenshots later on).  The problem comes when I try to render it, I believe my shader and loading code to be correct, however I only get a black square upon rendering.  I have been working on this for a couple of days now, trying lots of iterations and have even seperated out all of my framework code and have a completely barren example now that just loads up OpenGL and needed libraries and tries to render.

I am seriously at a loss as to what I am doing wrong, I am using GL_TEXTURE1 as my active texture but I originally started with GL_TEXTURE0 so I don't think that would be the problem.
Beyond that I can't think of anything that I am glaringly doing wrong; console output from Bitmap.cpp DOES output correct data (the image to display is 64x64) and when I dump the char* it outputs a large amount of data that was loaded into it.

EDIT

I managed to fix it, I honestly can't believe I missed this but when I switched from lodePNG to SOIL I never added the 4 lines that set the attributes of the images.  Adding these lines fixed everything right up and made it render

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Bitmap.cpp

GLuint BitmapLoader::Load(std::string path) {
    glEnable(GL_TEXTURE_2D);

    GLuint texture_id;
    glGenTextures(1, &texture_id);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture_id);

    image = SOIL_load_image(path.c_str(), &width, &height, 0, SOIL_LOAD_RGBA);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);

    std::cout << "Width: " << width << ", Height: " << height << std::endl;
    std::cout << "Image ID: " << texture_id << std::endl;
    std::cout << "Image Data: " << image << std::endl;

    SOIL_free_image_data(image);

    if (texture_id == -1) {
        return -1;
    }

    return texture_id;
}


texts: can i modify canvas outside Phaser's update or create functions?

texts:
can i create/change/destroy game objects (i.e. sprite, text) outside "create" function or "update" game-loop?

i'm working on a multiplayer game with nodejs and socket.io, and following is my former codes:

function create() {...}
function update() {...}
//the following codes are outside any state object
var socket = io.connect("xxx.xxx.xxx.xxx:xxxx");
socket.on("init", function(data) {
    game.add.sprite(0, 0, data.background);
    game.add.text(0, 0, data.title);
});

neither the sprite nor the text displayed correctly (sometimes display a "X" image)

then i move these codes to update function and it works fine:

var initData;
function update() {
    if (initData) {
        game.add.sprite(0, 0, initData.background);
        game.add.text(0, 0, initData.title);
        initDate = null;
    }
}
var socket = io.connect("xxx.xxx.xxx.xxx:xxxx");
socket.on("init", function(data) {
    initDate = data;
});

same thing happens when i wrote title.setText("new title") in socket.on function

so, is there any way i can directly modify canvas objects in socket's callback function ? sorry for my poor english :)


texts: Is it possible to render to multiple devices / monitors in XNA?

texts:
As the title.

If so, how?

As well as wiring it up correctly, how should I manage syncing GPU resources and update/draw steps?


texts: How do I draw a border around a display object in Corona Lua?

texts:
What would be the easiest way to draw a thin border around a rectangle image display object in Corona Lua?

This is what I tried:

Reviewed API and could not find a "border" method/property on displayObject
Have tried creating a black box slightly bigger behind object, however can not see how to place object behind an existing object hence question How do I move an existing display object behind another in Corona Lua?
Google results for putting a border around a display object in corona didn't help


texts: Scripts enable and disable on Random time unity?

texts: In unity game I've put two scripts in single object i want to these scripts are enable and disable on random time so how can do?


texts: Moving my character/camera makes environnement jerky

texts:
I'm learning to make a Tilebased game with Unity and for that I use the Zelda alttp assets.
I just have Tiles, a Camera and a moving Character with a rigidbody2D and a CircleCollider.

When the Camera follows the Character, the scene feels Jerky.

Info:

The Camera uses the 2D Pixel Perfect package.
The Character is moving via Rigidbody2D.MovePosition() in the FixedUpdate Method:

code:

void Update()
{
    float yInput;
    float xInput;

    #region yMovement
    if (Input.GetKey(keyMoveTop))
    {
        if (Input.GetKey(keyMoveBot))
        {
            yInput = 0f;
        }
        else yInput = 1f;
    }
    else if (Input.GetKey(keyMoveBot))
    {
        yInput = -1f;
    }
    else yInput = 0f;
    #endregion

    #region xMovement
    if (Input.GetKey(keyMoveLeft))
    {
        if (Input.GetKey(keyMoveRight))
        {
            xInput = 0f;
        }
        else xInput = -1f;
    }
    else if (Input.GetKey(keyMoveRight))
    {
        xInput = 1f;
    }
    else xInput = 0f;
    #endregion

    //Walking
    isWalking = Input.GetKey(keyMoveWalk);
    moveDirection = Vector2.ClampMagnitude(transform.right * xInput + transform.up * yInput, 1f);
}

private void FixedUpdate()
{
    _rb.MovePosition(_rb.position + moveDirection * (isWalking ? walkSpeed : runSpeed) * Time.fixedDeltaTime);
}

You can see the problem here:
https://youtu.be/MA2zZPME5X4

Edit: Added all my movement code


texts: How to disable Y-axis movement in the Bullet physics engine

texts:
I want to create an object than only moves along the the X and Z axes, while keeping the Y-axis disabled (it's like movement in 2D, and the object wont fall down).

I'm currently using a 6 dof constraint to restrict movement in the Y-axis, but it's not working:

btRigidBody* zeroBody = new btRigidBody(0, NULL, NULL); // Create the body that we attach things to
btRigidBody* robot = mCarChassis->getBulletRigidBody();

btGeneric6DofConstraint* constrict = new btGeneric6DofConstraint(*robot, *zeroBody, btTransform::getIdentity(), btTransform::getIdentity(), false);

constrict->setLinearLowerLimit( btVector3( 1, 1, 1));
constrict->setLinearUpperLimit( btVector3(-1, 1,-1));

constrict->setAngularLowerLimit( btVector3( 1,  1,  1) );
constrict->setAngularUpperLimit( btVector3(-1, -1, -1) );

mBulletWorld->getBulletDynamicsWorld()->addConstraint(constrict);

Thanks!


texts: Sprite cut in half after placed on Scene

texts:
I have noticed a very odd behaviour in Unity 5.2.1. When I drag and drop a Sprite into the Scene, it's cut in half like this:

I tried with PNG and PSD formats but it didn't help. Although when I flipped an image horizontaly in PS and then imported it, it worked. Is this a Unity bug?

Edit: It happens only when I set Max Size to 512 or more, but still - why?


texts: Raycast from ScreenCenter hits object but does not return its tag

texts:
Here is my code:

using UnityEngine;
using System.Collections;

public class Crosshair : MonoBehaviour {
    public Camera cam;
    RaycastHit hit;
    Quaternion rot;
    // Update is called once per frame
    void Update ()
    {
        int x = Screen.width / 2;
        int y = Screen.height / 2;

        Ray ray = cam.ScreenPointToRay(new Vector3(x,y,0));
        Debug.DrawRay(ray.origin, ray.direction * 100, new Color(1f, 0.922f, 0.016f, 1f));
        rot = Quaternion.FromToRotation(Vector3.up, hit.normal);

        if (Physics.Raycast(transform.position, transform.forward, out hit))
        {
            Debug.Log("Now trying to locate enemy...");
           if(hit.transform && hit.transform.tag == "Enemy")
            {
                Debug.Log("Enemy Spotted!!");
            }
            else
            {
                Debug.Log("I tried bro...");
            }
        }

    }
}

as I can imagine if(Physics.Raycast(transform.position, transform.forward, out hit)) is always false.

What am I not doing correctly?


texts: Best way to add animated sprites to canvas in Unity

texts:
In have a 3D world map, and I want to have a 2D UI with top nav/character thumbnail/stats/etc. overlaying it. I figured the best way to do this would be to use a canvas an embed all of UI stuff on it. For reference I'm going to be using this pack for the UI and this character as the thumbnail in case the issue I'm having is specific to these assets.

The character asset comes as a prefab that I tried to just drag and drop on to the canvas but it stays relative to the camera view (i.e. it looks really small on the canvas in scene view but bigger than all canvas elments in game view, and is positioned as it was relative to the world)

Heres some screenshot to help:

That tiny little dot inside the directional light is the sprite "on the canvas" next to the 3D world, you can see him in the camera preview. As you can see it's much smaller than the panel also on the canvas leading off screen.

Now when I hit play, he is much bigger than the canvas panel, and still positioned relative to the world:

Why isn't it treating the sprite like he is on the canvas, I tried setting it to the "UI" layer but no affect. It is nested under the canvas in the hierarchy.

Is there an easy way to make it act as a UI element while keeping the animations attached to him. And with the littlest effort as I'll be downloading many more of these sprites so I would prefer not to fully recreate them or anything.


texts:
I've started using Unity recently and have ran into some snags with the built audio features. I am trying to have multiple sounds play from the Player Game Object. I'm not sure what the best way to do this.

I have looked into solutions that involve changing the audio clip in the audio source. The problem I ran into with this method was that using the function "PlayOneShot" allows the sounds to stack. So if I try using this method for the walking noise it creates a new instance of that sound that layers on top of each other each frame the player walks. I figure I need to make just a player noise track that starts and stops depending on when the player is walking.

I've also considered trying to use multiple audio sources on the game object.

I'm really not sure what the best approach is for this and I'm having a hard to finding resources in this subject area.


texts: Writing a basic shader for large input files

texts:
I started writing a shader for my iOS app and instead of starting from scratch i used this tutorial here:
http://www.raywenderlich.com/3664/opengl-es-2-0-for-iphone-tutorial

I wrote an import function, first to import wavefront .obj models. My problem is that with I can't handle larger inputs (with a simple cube it was working). I realized that the indices array is an array of GLubyte values, which is unsigned char, so as a result i cant have more than 256 indexes. I modified it to GLuint, but then only get a blank screen.

What else needs to me modified?

p.s.: the source can be downloaded from here: http://d1xzuxjlafny7l.cloudfront.net/downloads/HelloOpenGL.zip


texts:
I remember something about onGui being able to be run multiple times per frame, and I also seem to recall that you can check 'which state' the onGUI is being run in, so that you can do all of the intense logic in just the part that gets run once.

Does anybody know what I am talking about --- I can't seem to remember what it was called and it is making googling it a daunting task. Thanks!


texts:
I am having a problem with a foreach loop. When my AOE ability hits an enemy it creates a CircleCollider2D and puts all the enemies on a list, which then the loop goes through and adds damage to their scripts.

private void OnTriggerEnter2D(Collider2D other)
{
    if(other.tag == "Enemy")
    {
        targets.Add(other);

        foreach (Collider2D enemy in targets)
        {
            EnemyHealth hp = enemy.GetComponentInChildren<EnemyHealth>();

            hp.TakeDamage(abilityConfig.baseDamage);

            print(enemy.name + " takes " + abilityConfig.baseDamage + "damage!");
        }
    }
}

But as you can see from the picture below the loop goes 3 times over one enemy, 2 times over the second one and once over the third.

As these enemies are the same type they all have the same EnemyHealth script.
If anyone would point me in the right direction I would greatly appreciate it.


texts: Unity - How to set IK position of Left Hand with an offset?

texts:
I have a character holding a stick with left hand. I am using IK to make the stick hit a target position. When I position left hand at target position, it works fine. But, I need to offset the hand such that the end of the stick hits the target position. For this, I have put an empty game object as a child at the end of the stick, and offset it like in the code below, but the hand just keeps jittering like crazy. I know it is quite possible to do, but somehow I seem to be missing something. Please help me!
[SerializeField] private GameObject target;
 private Vector3 leftHandPosition;
 private Vector3 hitChildPosition;

 private void OnAnimatorIK(int layerIndex)
 {
         Vector3 t = target.transform.position - (hitChildPosition - leftHandPosition);
         animator.SetIKPosition(AvatarIKGoal.LeftHand, t);
         animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
 }

 private void LateUpdate()
 {
         hitChildPosition = BatHit.transform.position;
         leftHandPosition = animator.GetBoneTransform(HumanBodyBones.LeftHand).position;
 }

Here's an image to visualise what I'm trying to solve -


texts:
Posting this here because I spent several days trying to figure out why I couldn't rotate my entities the way I wanted to in Unity.
For a little bit of background, I'm creating a flight dynamics model using Unity's Entities package. Part of this project involves providing keyboard input to a system in order to manipulate the motion of an aircraft--a very basic simulator.
I encountered an issue when I tried rotating my aircraft entity using the Rotation.Euler() method. In fact, just about every approach I saw on every forum I visited could not provide the answer I was looking for. My keyboard input logic manipulated the bank angle (roll), alpha (pitch), and yaw, and I was trying to set an absolute angle for my entity based on those values. It seemed that I was unable to set the rotation values the way I would in the inspector panel, since rotating the entity one direction would make rotating it along another axis unpredictable.
Such is the nature of quaternions.
Thus, I found a solution to my issue, involving a simple helper function that converts a float3 array of rotation values (one for each axis) to a quaternion. I'll be posting the code and explanation in the answer below.
EDIT: In the previous iteration of my code, this is what I had tried in order to update my entity's rotation:
Vector3 temp = transform.rotation.eulerAngles;
temp.x = -90.0f + state.bank;
temp.y = 0.0f;
temp.z = state.alpha;

Entities.ForEach((ref Translation translation, ref Rotation rotation, ref AircraftData aircraftData) => {
            translation.Value = position;
            rotation.Value = Quaternion.Euler(temp);
        }).Schedule();

All other code within the answer below was the same (minus the new quaternion calculations).


texts:
I need to simulate my background scrolling but I want to avoid moving my actual image control. Instead, I'd like to use a WriteableBitmap and use a blitting method. What would be the way to simulate an image scrolling upwards? I've tried various things buy I can't seem to get my head around the logic:

 //X pos, Y pos, width, height
 Rect src = new Rect(0, scrollSpeed , 480, height);
 Rect dest = new Rect(0, 700 - scrollSpeed , 480, height);

 //destination rect, source WriteableBitmap, source Rect, blend mode
 wb.Blit(destRect, wbSource, srcRect, BlendMode.None);
 scrollSpeed += 5;

 if (scrollSpeed > 700) scrollSpeed  = 0;

If height is 10, the image is quite fuzzy and moreso if the height is 1. If the height is a taller, the image is clearer, but it only seems to do a one to one copy. How can I 'scroll' the image so that it looks like it's moving up in a continuous loop? (The height of the screen is 700).


texts: Determining which edge of a box was clicked in Unity

texts:
How would I go about figuring out which edge of a box is clicked in Unity?

Quick image I created, colored in boxes represent edges on a face I would like to check for.

The current solution I have is half working. I create a raycast, check if it collided with a box, get the normal from the hit (to determine which side it collided with) & check if the point meets the criteria for X, Y, or Z (in the buffer zone, as outlined in the image). For example, if the raycast intersects the forward face I check that the point is inside one of the X buffers and not in one of the y buffers.

Currently only 2 sides on the forward / backward face work, as shown below

Finally, the related code.

void forwardMethod(RaycastHit hit){
    if(intersectsX(hit.point, hit.transform) && !intersectsY(hit.point, hit.transform)){

    }
    else if(intersectsY(hit.point, hit.transform) && !intersectsX(hit.point, hit.transform)){

    }
}

bool intersectsX(Vector3 hit, Transform transform){
    float buffer = transform.localScale.x * edgeBufferPercent;
    return hit.x <= buffer || hit.x >= transform.localScale.x - buffer;
}

bool intersectsY(Vector3 hit, Transform transform){
    float buffer = transform.localScale.y * edgeBufferPercent;
    return hit.y <= buffer || hit.y >= transform.localScale.y - buffer;
}

bool intersectsZ(Vector3 hit, Transform transform){
    float buffer = transform.localScale.z * edgeBufferPercent;
    return hit.z <= buffer || hit.z >= transform.localScale.z - buffer;
}

The buffer is equal to .15 if anyone is interested in that as well.

Any ideas? Am I approaching this wrong or is there a bug in my code I'm not seeing?


texts: Export information to a custom file type from Air

texts:
So I have an engine (air application) that basically (for now) is loading some windows on the screen/stage, and you can drag them around. And later on, I'll be able to add other objects onto the stage.

How would I export any kind of information (like co-ordinates or sizes of windows) out of my application to an external custom file. And then I would use that file to reload a previous project if I were to re-load the engine.

I'm working in AS3/Air and in FlashDevelop.

Thanks for the help and time. If anymore information is needed please let me know.

Cheers.


texts: LibGDX: I need to get from SpriteBatch to Batch in order to draw a Touchpad

texts:
I have created a little game using LibGDX and it uses a SpriteBatch when it renders the game objects. Now I want to add a Touchpad to it, and the draw method of Touchpad takes a Batch as a parameter, but my game uses SpriteBatch.
What can I do?


texts:
I am using the LibGDX framework. I'm not using Scene2D but I want to implement my own "scrolling UI". This is only what I could think of (see image below):

I will make the 2nd camera look at very far coordinates (and draw the UI stuff there) and have it (within the blue box) receive its own input. But I think this is not possible with LibGDX, since if you set the size of the camera you are like setting how big it views the world and not how big the viewport is. I mean you can't set the size of the camera of something like 50px width and height and have it place on the center. If you setPosition, you are setting it to where it looks at and not where it is placed in the 2D space. I'm trying to explain it clearly and I hope it is clear.


texts: Every X months Visual Studio Code says: 'UI' does not exist in the namespace 'UnityEngine'

texts:
I've tried countless fixes in the last 1,5 year, and I still don't know what is the absolute fix for this. Or after fixing it, why it got fixed.
Usually this happens after a Unity update, or after updating the IDE packages.
I tried lots of fixes, and it seems like that it's always changing what fixes it:

Sometimes it's fixed by regenerating all projects files, also sometimes manually deleting them.

Sometimes it's fixed by reinstalling Visual Studio.

Sometimes it's fixed by downgrading the IDE packages (until now not for me, but based on some browsing, it works for some people)

Switching to Visual Studio in the preferences, opening it, then switching back to Code. (At first I thought that this is just regenerates the projects files, but who knows, maybe it does something else in the background.)

This time it got fixed after I switched to Visual Studio, opened Visual Studio, and it showed missing references. So I closed it, regenerated all project files, and then reopened it. Now Visual Studio works. And after this, I switched back to Visual Studio Code, and now it works there as well.

(I always restart Unity and Code after these)
Sometimes it isn't fixed by just going through this list one by one. Sometimes none of them fix it, so I try them all again, in different order, etc, and then it's fixed after some random combination.
Most of the times only Visual Studio Code is broken, but sometimes Visual Studio is missing the references as well.
Could someone tell me why this keeps occurring for a lot of people, and what is the absolute fix and why?
In the log, it says that UnityEngine.UI got successfully loaded and added:
OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'c:\Projects\RPG\UnityEditor.UI.csproj'.
OmniSharp.MSBuild.ProjectManager
Adding project 'c:\Projects\RPG\UnityEditor.UI.csproj'


texts: Given the size of far and near plane, find other parameters of a frustum

texts:
I am trying to find the correct parameters for setting up my perspective camera. But I don't know the mathematics involved in that. Can somebody point me to the right direction?

My near plane should have width 1920 and height 1080 while my far plane should have width 3840 and height 2160. Aspect ratio is 1.7

Now how do I get the appropriate fovy, near plane distance and the far plane distance so that I get the desired frustum?

Edit: The world size is 3840 x 2160, and the entire world is divided into four quadrants. The size of a quadrant is 1920 x 1080. The user can zoom out and look at all four quadrants (Eagle eye view) or zoom in and look at one quadrant at a time. The important thing is, the world size should always be twice the size of a quadrant (and the area should be four times the area of a quadrant). When the game is actually being played, I just modify the Z position of the camera to zoom-in/zoom-out. Decrease the Z position to zoom in, increase the Z position to zoom out.


texts: PCF shadow shader math causing artifacts

texts:
For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving performance, with only a fraction of texture samples, I tried to implement PCF into my shader. This is the relevant code:

float c0, c1, c2, c3;
float f = blurFactor;
float2 coord = ProjectedTexCoords;
if (receiverDistance - tex2D(lightSampler, coord + float2(0, 0)).x > 0.0007)
    c0 = 1;
if (receiverDistance - tex2D(lightSampler, coord + float2(f, 0)).x > 0.0007)
    c1 = 1;
if (receiverDistance - tex2D(lightSampler, coord + float2(0, f)).x > 0.0007)
    c2 = 1;
if (receiverDistance - tex2D(lightSampler, coord + float2(f, f)).x > 0.0007)
    c3 = 1;

coord = (coord % f) / f;
return 1 - (c0 * (1 - coord.x) * (1 - coord.y) + c1 * coord.x * (1 - coord.y) + c2 * (1 - coord.x) * coord.y + c3 * coord.x * coord.y);

This is a very basic implementation. blurFactor is initialized with 1 / LightTextureSize. So the if statements fetch the occlusion values for the four adjacent texels. I now want to weight each value based on the actual position of the texture coordinate. If it's near the bottom-right pixel, that occlusion value should be preferred. The weighting itself is done with a simple bilinear interpolation function, however this function takes a 2d vector in the range [0..1] so I have to convert my texture coordinate to get the distance from my first pixel to the second one in range [0..1]. For that I used the mod operator to get it into [0..f] range and then divided by f.
This code makes sense to me, and for specific blurFactors it works, producing really smooth one pixel wide shadows, but not for all blurFactors.
Initially blurFactor is (1 / LightTextureSize) to sample the 4 adjacent texels. I now want to increase the blurFactor by factor x to get a smooth interpolation across maybe 4 or so pixels. But that is when weird artifacts show up. Here is an image:
Using a 1x on blurFactor produces a good result, 0.5 is as expected not so smooth. 2x however doesn't work at all. I found that only a factor of 1/2^n produces an good result, every other factor produces artifacts.
I'm pretty sure the error lies here: coord = (coord % f) / f; Maybe the modulo is not calculated correctly? I have no idea how to fix that. Is it even possible for pixel that are further than 1 pixel away?


texts:
I'm currently writing a generic engine for my incoming games. I have developed few games already but never with the same "base" and my code was/is quite a mess. The idea was to create an engine that I could use for any type of games.
I have read papers about entity/components managers. Some are using what they call nodes, systems etc... I thought it was a bit confusing, especially the node concept. I plan to not use nodes, and my question essentially is: "Is this a good engine concept"? And if it is not, what improvements could I make?

First, all elements in my game are entities. The player is an entity, any tile of the map or whatever is an entity. An entity (in my engine) is a basic class with a position, and a list of components. In my mind, all "features", "behaviors", etc, must be implemented through components. The entity class will also have an update and a render method. The entity holds an unique special component that is a component that implements an interface 'Renderable' and will handle the rendering of the entity, an entity that does not need to be rendered will not have a render component.

That was for the entity, now about component. Currently in my engine a component is something that brings something to the entity. For example, if I want my entity to be controllable via keyboard or whatever, I will add a component that handles this to my entity. And during the engine update process, the entity manager will update all its entities and each entity will update all its components (or at least the components that need to be updated).

class KeyboardControllComponent extends AbstractComponent implements Updatable {

    @override
    public void update() {
        //do the input handling here
    }

Basically this component will call another one (a movement component) that will actually apply the movement to the entity.

Also, I have implemented what I call a 'dispatcher' to my engine. It allows all elements to the game (everything in my game extends a GameElement class) to dispatch or listen for events. For example, if the hero walks on a specific thing (a trap for example), the component in charge of the hero entity movement/collision will fire an event to all game elements that are actually listening for that kind of events. I will take the example of an interrupter, the hero 'collide' this interrupter, the interrupter component in charge of collision will then fire a event to the entity that represents a door somewhere and open it.

Is this a good concept?

Finally, all game elements are handled by managers. EntityManager, DispatcherManager, SceneManager, etc...

Let me know what you think of my approach. I have not added actual code using the engine to not overload the post but if you want to see it, no problem.


texts: Animation "Offset" in Unity 2D animation

texts:
I was playing around with Unity and its 2D Animator. When I press a Button now (to play for example the walk left Animation) it takes about 1 sec to begin the animation and same when I release the button to stop it. It's the same problem with every other animation.

Here's my Player Movement Controller:

using System.Collections;
using UnityEngine;

public class Player_Movement : MonoBehaviour {

public float speed = 10;
float old_pos;
float old_height;

void Start()
{
    old_pos = transform.position.x;
    old_height = transform.position.y;
}

void FixedUpdate()
{

    float h = Input.GetAxisRaw("Horizontal");
    float v = Input.GetAxisRaw("Vertical");

    Vector2 dir = new Vector2(h, v);
    GetComponent<Rigidbody2D>().velocity = dir.normalized * speed;

    GetComponent<Animator>().SetBool("isWalkingLeft", (h < 0));

    GetComponent<Animator>().SetBool("isWalkingRight", (h > 0));
  }
}

The problem also occurs when I switch directions and the animation should instantly switch over.


texts: Random equidistant points like a tree branch (JS)

texts:
I'm working on an algorithm to generate a "graph" like array of points in my game world. See Image Below:

Here is what i'm working on so far, which will generate the black line.. but this may not be the best route.

var angle = Math.random()*Math.PI*2;
var rx = Math.cos(angle)*radius + lastPointX;
var ry = Math.sin(angle)*radius + lastPointY;
lastPointX = rx;
lastPointY = ry;
points.push(new GamePoint(0, game, rx, ry));

I'm trying to expand upon this to make various other "branches" to add a randomness to the game but at all times the player has to have at least one option to move forward ( if not more ). Paths can cross but shouldn't get too close / overlap.

I'd eventually want the game to consist of multiple paths ( see image below ). The player will move up but doesn't see the whole "graph".


texts: How to render a bevel effect with SDL2 Texture?

texts:
I develop 2D games using CodeBlocks (C++) with SDL2.

I can load a texture (ex. a gray square) and render it to the screen. All is fine. If I want to change the color of the square? Yes, I can do it. I can rotate too, without an issue.

But here's what I'd like to know:

I'd like to render the square border with a bevel effect. This is for displaying icons on the screen: I'd like to avoid having to load 2 images, one for the icon picture (with a transparent background) and one for the bevel; I'd like to add the bevel effect on some parts, dynamically in the program.

How can I do it?


texts: Calculate current level and level requirements when only XP is being updated

texts:
I am trying to create a formula to calculate the players level based on his XP alone. The game currently only increments his XP after certain actions.

I have the formula for calculating the required XP to level up:

var baseXP = 500;
var exponent = 1.04;
var requiredXP = Math.floor(baseXP + (baseXP * Math.pow(user.level - 1, exponent)));

The purpose of this formula is to increment the required level as so:

Level 1: 0-499xp
Level 2: 500-1527
Level 3: 1528-2066
Level 4: 2067-2613
Level 5: 2614-4165
etc...

I'm not sure if the formula is exactly what I need to use, and the exponent value is just arbitrary (incremented/decremented to make leveling take more/less time)

How would this formula be used or reversed to calculate the players current level. As a plus, any way to limit the maximum level to 100.

Thank you


texts: Differences between storyboarding for game design vs. web design

texts:
I'm looking to UX and storyboard out a web adventure game. The goal being to have an area to show what the UI/UX would look like (mockups), and ability to add dialog/blurbs to describe the screen.

I was thinking InVision, but that seems strictly for web development mockups. I could also simply draw them in Photoshop or on paper, but was looking more for something game design specific.

Are there significant differences between storyboarding for game design as opposed to web design? If so, how do UX or storyboarding tools cater to those differences?


texts: Render model with meshes with materials and/or textures

texts:
I'm making a model class that is using Assimp in the background. I want my models' meshes to be able to have a material and an optional texture on top of that.

Right now I'm doing it like this: for each mesh, I store postion, normal, and texCoord for each vertex in that mesh. If the mesh doesn't have a texture, I just add vec2(0.0, 0.0) to the texCoord-array. I needed to add blank values for the meshes that doesn't have textures so the offset for the meshes that has textures would be correct.

At first I thought this would work. To draw the meshes I use the same shader-program for both the meshes without textures and the ones with textures. But since no texture will be bound when I render the ones without textures, it will sample tex-colors from nothing (?), and flickering occurs.

So my question is, what would be a good way to solve this? Is it possible to have two shader-programs and switch between them depending on if the model has a texture?


texts: Must know legal issues when releasing a game?

texts:
Alright, some day in the far future I would love to independently release my own game.

My question is, what is the minimum amount of familiarity I need with copyright law, software patents, and other forms of intellectual property in order to protect myself and property while not accidentally infringing upon another company's property?


texts:
I am doing volumetric raycasting and curently working on depth jitter. I have 3D position on ray and want to sample 2D noise texture to jitter the depth.

Function for converting (or hashing) 3D position to 2D have to produce absolutely different numbers for a little changes (especialy because i am sampling in texture space so sample values differs very very little) and have to be "shader-wise" - so forget about branches, cycles etc.

I'm looking forward for yours nice and fast solutions.


texts: Get sprites from XML and spritesheet in Java

texts:
I have a SpriteSheet that have a lot of images in one in .png format, and the XML file with the all names of every sprite (x,y,width,height) like this:

<TextureAtlas imagePath="sheet.png">

<SubTexture name="box.png" x="0" y="864" width="70" height="70"/>

</TextureAtlas>

Im using Slick2D to make a BasicGame, SpriteSheet and XStream lib to manage the sprites, but i cant do, that load the image correctly. How I can do?


texts: How do I draw shape distortion with a Texture2D in XNA?

texts:
Say I have a rectangular Texture2D object in XNA, and I draw it on the screen.
How can I animate it so it slowly changes to a trapezoid shape, and then to a pentagon, etc.

I have no idea what this technique is called, so I couldn't find anything on Google.


texts: Behvior of Ninepatch when smaller then unstrechable area?

texts:
I create a healthbar from a Ninepatch background and "fill" texture. However, it starts overlapping it's patches when it gets very small.

Is there anything I can do about this? Is there a way to tell the Ninepatch  not to draw the stretchable area and just draw a part of it or perhaps shrink in size?

float maxFill = getWidth() - horizontalOffset * 2;
float currentFill = (maxFill / max) * current;

//This is how I currently fix it.
//Whenever it gets less then it's own total size it just does not get smaller.
if (currentFill < minFill) currentFill = minFill;

fill.draw(batch, getX() + horizontalOffset, getY() + verticalOffset, currentFill, drawHeight - verticalOffset * 2);

The not really desirable work arounds I have thought about are.

Don't use rounded ends
Dump the ninepatch and start masking/clipping
Stop the Ninepatch from getting too small like I did above.

edit

Zoom in on the image I posted, in the red healthbar you can see the issue. The stretchable area is being drawn over the unstretchable area. The desired effect of the bar should just clip the rounded unstretachable area when getting smaller then the 2 unstretchable parts together.


texts: How many achievements should I include, and of what challenge?

texts:
I know this question is fairy broad and subjective, but I'm wondering if there's been any published research into what an optimal number of achievements is and what kind of challenge they should present. The game this question directly relates to is a shoot-em-up, but an ideal answer is fairly theoretical.

If there are too few achievements, or they are not challenging, I would expect they would fail in their goal to keep people playing. If there are too many, or they are unreasonably difficult, I would expect people to quickly give up. I personally witnessed the latter happening in Starcraft 2; a section of the achievements would have you win hundreds of games against their AI opponents (boring!)


texts:
I am developing a stealth game. In the game when enemy sees player he starts chasing it. But there are a lot of covers. If player just goes behind of a wall it will be out of sight for this enemy. But I want my enemies little bit more realistic.

So i did do some further implementations... For example if player goes out of sight enemy remembers last seen position and goes there anyway.

Than i save the move direction of player on the position where he was last seen. So when enemy goes there he looks this direction which he may probably catch a glimps of the player and start chasing again.

But if player is still no where to be seen I want my enemy to look around little bit, search for the player maybe. I couldnt come up with an algorithm to do that.

Also if on the last seen position and last move direction there is another wall, enemy goes this position and looks stupidly to the wall which also dont seem realistic at all...

Does anybody have any suggestions?


texts: Libgdx are textures off screen rendered?

texts:
Let's say that my code looks like this:

OrtographicCamera camera=new OrthographicCamera();
camera.setToOrtho(true, 100, 150);
SpriteBatch spriteBatch=new SpriteBatch();
spriteBatch.setProjectionMatrix(camera.combined);
TextureRegion textureRegion = textureAtlas.findRegion("redCircle");
spriteBatch.begin();
spriteBatch.draw(textureRegion, 200, 200);
spriteBatch.end();
//This will try to render a TextureRegion outside of the OrthographicCamera's field of view

My question is: should I write my code so that it checks everytime the coordinates of what I am trying to draw, detects if it's offscreen, and in that case skips it (to spped up the rendering), or does Libgdx already do that for me?


texts:
I´m trying to implement a microfacet BDRF with GGX density function in my renderer. I have read almost all the papers out there in the last week, and I have a bunch of equations that should work fine, but I think they don´t. My problem is that the normalized functions of the BDRF are returning specular values way over 1:

I´m using Schlick's approximation for the fresnel term, the only one that is returning values in the range [0-1]:

F = oSpecular + ( 1.0 - oSpecular ) * ( 1.0 - L.H )^5 ;

The normalized GGX distribution function with a being the roughness:

D = a^2 / ( PI * N.H^2 * ( a^2 - 1.0 ) + 1.0 )^2

The Geometric factors I´m using:

G1 = 1.0 + sqrt( 1.0 + a^2 *( ( 1.0 - N.L^2 ) / ( N.L^2 ) ) ) ;
G2 = 1.0 + sqrt( 1.0 + a^2 *( ( 1.0 - N.V^2 ) / ( N.V^2 ) ) ) ;

And the full BDRF:

nSpecular = D * F * G1 * G2 / ( 4.0 * N.L * N.V )

I have seen this setup used widely. But even with the N.L factor it returns values over way 100.0 in the hotspot of the light reflection. I have tryed other Geometric terms with no luck. The BDRF is always overburned. It seems that I´m missing some important point here. Any idea?

Edit:

Thanks for the answer. So for area lights using representative points energy conservation is only an aproximation, wich explains why with low intensity lights the reflection can be still a lot brighter than the light source itself, wich is a pitty, and does not look right at all. I will try to look for another method. Any suggestion?

Returning to the original question about point lights with GGX and energy conservation, there is a thing I´m still missing. As the NDF returns a density probability function, wich can have values way over 1, that means that you can´t use the value as returned from the NDF directly in the shader, can you? As the specular component is later multiplied by the light source power, it should be really in the range 0-1, or you will have specular reflections 400 times brighter than the light source itself, with has no sense. Tell me only about one real life situation when a reflection in a dx returns 400 more energy than it receives and we can do business. The density probability function should be weighted or interpreted somehow to return it to a propper 0-1 range? If so, why nobody does that?


texts:
I finished a game in Java. It works perfectly fine on my computer.

Sent it to a friend. On his computer, for some reason, one of the keys that are used to play doesn't work inside the game. (It works in any other context, like a web browser).

He tried pushing this key with no other keys held. Still didn't work. So it's not a 'key combination' issue.

We both use Windows and the most updated JRE version.

What could it be? This is really weird. Thanks


texts:
I'm trying to leave the second dimension and finally make a 3d game, but I'm having a hard time coming up with a way to implement a certain concept. I am trying to make a flat object which would "stick to walls." It's a bit difficult to explain, so I'll just add a picture here.

The way I see it, there are a few parts to this problem. Firstly, how would I specify which edge on one polygon leads to an edge on another?
Secondly, how would I make sure that the object never gets excessively deformed when on a corner of 3 or more edges? (As in, how do I assure the gaussian curvature always stays as 0) And thirdly, how would I split the object along the two surfdaces it's on without having a ton of polygons?

I'm not sure what engine I'll be programming this in yet, because as I said, it's my first foray into 3d, so if responses could either just explain concepts or use pseudocode, that would be optimal, but if you want to use examples from a specific language it'll work.

Thanks in advance for anyone who wants to respond!


texts:
So here is the thing:
I have made a thread for each generator an outpost has. We have a total of 6 outposts , 5 generators each. 3 teams, engineers can only repair generators and prevent their overload. In order to make the whole generator logic I use threads. If the thread gets interrupted it means that the generator got prevented from being destroyed , if the thread is finished normally , the generator got destroyed and if the generator is destroyed an engineer can repair them. Is there any way of avoiding threads because in spite of high cpu usage there are also other thread issues.

The same thing happens with the shield regeneration of each player. I'll just post the code for this one:

public static void startRegenerate(final Player p){

    if(already_regenerating_arraylist.contains(p.getId())){
        return;
    }

    final int previous_shield_lvl = p.getShieldLevel();
    final int previous_hp_lvl = (int) p.getHealth();

    Thread reg = new Thread(){

        @Override
        public void run(){

            already_regenerating_arraylist.add(p.getUniqueId());
            try {
                sleep(3000);
            } catch (InterruptedException e1) {
            }

            for(;;){

                if(p.getShieldLevel() >= 20){
                    p.setShieldLevel(20);
                    already_regenerating_arraylist.remove(p.getUniqueId());
                    break;
                }

                if(p.getHealth() < previous_hp_lvl || p.getShieldLevel() < previous_shield_lvl){
                    already_regenerating_arraylist.remove(p.getUniqueId());
                    break;
                }

                p.setFoodLevel(p.getFoodLevel() + 6);

                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                }
            }

        }

    };

    reg.start();
}

After having more than 50 players stuff stop working (lag , etc...)


texts: How do I calculate/weight a diminishing damage formula based on N targets?

texts:
I'm making a game and had a look at the questions about calculating damage/diminishing returns here and here but I haven't quite been able to come up with a logarithmic function that satisfies this goal - which is probably super obvious to those mathematically minded of you (apologies if it is!).
The goal is:

deal half of the damage total to the first target
deal a diminishing amount of damage for each target beyond the first
do not deal more damage than is input into the function
bonus: create a linear downward curve

An example (what I've got so far):
fn = (amount, count) => {
 let d = amount;
 let r = 0.5;
 let a = [];

 for (i = 0; i < count; i++) {
   a.push(d * r);
   r -= r/(count-i);
 }

 a.push(a.reduce((acc, cur) => acc + cur)); //push the total combined damage output as last result of array
 return a;
}

You can probably spot the problem! Given 300 damage and 3 targets (fn(300, 3)), this outputs the following: [150, 100, 50, 300] - which is great. The last number is just the total amount of damage being dealt, which with these inputs matches the amount fed into the function.
Given 4 targets and 400 damage, the problem is exposed with the output being: [200, 150, 100, 50, 500] - the damage output is 100 more than the input amount.
This is not a game breaking problem for me and it's also not that important that the downward curve be linear, but if there is a way to achieve that result that would be awesome and I would greatly appreciate any input!
Thanks for your time!


texts: In a casual top-down racing game, should collisions affect the car's engine?

texts:
Is there a way to deter players from colliding with obstacles in a top-down casual racer which keeping the game fun and lighthearted and yet make player's skill matter?

Should collisions affect car engine performance in a casual racing game? If so, in what way could it be done that keeps it fun?

Please use references (to other games) and examples in your answers.


texts: How do I customise automatically-generated script?

texts:
When you create a script via the Unity editor, it generates a script with some pre-formatted code.

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

public class GenericClass : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

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

    }
}

When I create a script, I am generally guaranteed to use additional code, such as a namespace or a custom editor. Furthermore, I almost always delete content from the automatically-generated script. Is there a way to change the automatic code generated by Unity?


texts: Is there a purpose behind the tediousness of most MMO RPGs?

texts:
As most of you probably know a lot, if not all, MMO RPG games have some element of "tediousness" in them.

By "tediousness" I mean elements in the gameplay that feel both unpleasant and needlessly complicated or long (note that grinding is simply unpleasant and therefore I do not include it in this question).

For example - introductory quests.
I don't mean the idea of introductory quests, which I think good. I mean their implementation.

For example in some games, where you can have several characters per account, each time you create a new character you have to go though the same introduction. You are not offered the option to skip it, regardless that you might already have a high leveled character. Surely there must a point to this?

For another example in some games the introduction is needlessly long. It could take an average player a few days to get past it, it doesn't add anything storywise and the game concepts have long been explained by the time the player reaches even half.

What is the rationale behind putting the player through all this, instead of giving him the option to skip the intro and/or making it only as long as it needs to be, etc.?


texts: 2D Side Scrolling game and "walk over ground" collision detection

texts:
The question is not hard, I'm writing a game engine for 2D side scrolling games, however I'm thinking to my 2D side scrolling game and I always come up with the problem of "how should I do collision with the ground".
I think I couldn't handle the collision with ground (ground for me is "where the player walk", so something heavily used) in a per-pixel way, and I can't even do it with simple shape comparison (because the ground can be tilted), so what's the correct way? I'know what tiles are and i've read about it, but how much should be big each tile to not appear like a stairs?Are there any other approach?

I watched this game and is very nice how he walks on ground:
http://www.youtube.com/watch?v=DmSAQwbbig8&feature=player_embedded

If there are "platforms" in mid air, how should I handle them?I can walk over them but I can't pass "inside". Imagine a platform in mid air, it allows you to walk over it but limit you because you can't jump in the area she fits

Sorry for my english, it's not my native language and this topic has a lot of keywords I don't know so I have to use workarounds
Thanks for any answer

Additional informations and suggestions:
I'm doing a game course in this period and I asked them how to do this, they suggested me this approach (a QuadTree):
-All map is divided into "big nodes"
-Each bigger node has sub nodes, to find where the player is
-You can find player's node with a ray on player position
-When you find the node where the player is, you can do collision check through all pixels (which can be 100-200px nothing more)

Here is an example, however i didn't show very well the bigger nodes because i'm not very good with photoshop :P

How is this approach?


texts: Getting mouse movement value with DirectX Tool Kit

texts:
today I want to ask a question about how to get mouse movement value with DirectX Tool Kit.

While I can certainly use Mouse::SetMode(MODE_RELATIVE), to do this, I want to be able to get the mouse cursor position at the same time (which can only be done with MODE_ABSOLUTE).

The method I thought of involves leaving mouse mode as the default MODE_ABSOLUTE, and then subtract the mouse position from the previous frame from that of the current one.
But with this method, the mouse cursor can jump out of the window.

So I thought of restricting the mouse cursor to a certain point, but this obviously prevents me from calculating the movement value with said method.

Does anyone have some ideas on how to achieve this with DirectX Tool Kit ?
Or am I missing some obvious thing ?

Thanks in advance!


texts: Why doesn't SDL_Mixer play my audio file?

texts:
I'm coding a game in SDL2 and I'm implementing the audio system using SDL_Mixer. However, my music file won't play during the program and I don't know why. How do I get the music to play?

Audio initialization:

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);

Opening the audio device:

if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0)
    std::cout << "Error:" << Mix_GetError() << std::endl;

Loading the sound file:

Mix_Chunk *soundEffect = Mix_LoadWAV("Sound\BetaMusic.wav");

Playing the sound file:

Mix_PlayChannel(-1, soundEffect, -1);


texts: How to find the 3D object the camera is pointed at

texts:
I'm currently developing a 3-dimensional game (the first I've ever done and it's not as hard as I thought it would be!), but I've run into a little bit of a snag. I want to find the current block the crosshairs of the camera are pointed to, and I'm not sure how exactly to do it. The only thing I can think of is starting at the view position and moving like 0.1 units until I hit a space that is occupied by a block, but I feel like that would be a little... brute-force style? Is there an easier/better way to find it?

Here's what I have:

The vector3 of the camera position.
An array of block positions which may or may not be filled with blocks. The block centres are at whole-numbered intervals.

I promise this isn't a minecraft clone. ;)


texts: XNA: My bullets lag the game the first time they're fired, but not after

texts:
I'm working on a SpaceWar-esque project to get comfortable with XNA. I have a Ship DrawableGameComponent and a Bullet DrawableGameComponent. The player's Ship is created at the start of the game, and the Bullets are created for each Ship as part of its constructor.

In my Ship constructor, I have the following code:

for (int i = 0; i < 5; i++)
{
    activeBullets[i] = new Bullet(game);
}

The relevant part of my Ship's shoot() function is as follows:

activeBullets[bullet].Visible = true;
activeBullets[bullet].Enabled = true;
activeBullets[bullet].position = this.position;

The first five times I shoot() (that is, once for each bullet object that the ship is allotted), there is lag that I think is due to the bullet sprite being loaded. I've tried setting Visible and Enabled to true in the ship constructor loop where the Bullets are instantiated, but the first-five-shots lag persists. Any shots beyond the first five are completely lag-free.

How do I load the Bullets properly ahead of time so that there is no lag on the first shots?


texts: The View-Matrix and Alternative Calculations

texts:
I'm working on a radiosity processor in DirectX 9. The process requires that the camera be placed at the center of a mesh face and a 'screenshot' be taken facing 5 different directions...forward...up...down...left...right...

...The problem is that when the mesh face is facing up( look vector: 0, 1, 0 )...a view matrix cannot be determined using standard trigonometry functions:

Matrix4 LookAt( Vector3 eye, Vector3 target, Vector3 up )
    {
        // The "look-at" vector.
        Vector3 zaxis = normal(target - eye);
        // The "right" vector.
        Vector3 xaxis = normal(cross(up, zaxis));
        // The "up" vector.
        Vector3 yaxis = cross(zaxis, xaxis);
        // Create a 4x4 orientation matrix from the right, up, and at vectors
        Matrix4 orientation =
        {
            xaxis.x, yaxis.x, zaxis.x, 0,
            xaxis.y, yaxis.y, zaxis.y, 0,
            xaxis.z, yaxis.z, zaxis.z, 0,
            0,       0,       0,     1
        };

        // Create a 4x4 translation matrix by negating the eye position.

        Matrix4 translation =
        {
            1,      0,      0,     0,
            0,      1,      0,     0,
            0,      0,      1,     0,
            -eye.x, -eye.y, -eye.z,  1
        };
        // Combine the orientation and translation to compute the view matrix
        return ( translation * orientation );
    }

The above function comes from http://3dgep.com/?p=1700...

...Is there a mathematical approach to this problem?


texts:
This simulates a GameObject swinging between two positions.

I am unable to manually move a GameObject on the Y axis using the Unity editor (in scene view) when the following script is attached and running, it's like a solid animation:

Vector3 min, max;

void Update()
{
    min = wall1.position + new Vector3(4,0,0);
    max = wall2.position - new Vector3(4,0,0);

    transform.position = Vector3.Lerp (min, max, (Mathf.Sin(2 * Time.time) + 1.0f) / 2.0f);
}


texts: Where can I learn about Substance maps for 3ds Max 2012?

texts:
A new feature in 3ds max 2012 is Substance procedural textures.

Are there any good online libraries or resources for substance maps?


texts: The jumping height changes randomly, and it is not due to the fact that I press the space bar longer. It is just random

texts:
Sometimes, the jump height will be so high, and sometimes it jumps normally. How do I solve this? Code:

using UnityEngine;

public class PlayerController : MonoBehaviour
{

    [SerializeField] private LayerMask platformsLayerMask;

    public Rigidbody2D rb;

    public float MovementSpeed = 100f;

    public float JumpingHeight = 100f;

    public BoxCollider2D bc;

    public float fallMultiplier = 2.5f;
    public float lowJumpMultiplier = 2f;

    public Animator anim;

    void Awake()
    {
        rb = transform.GetComponent<Rigidbody2D>();
        bc = transform.GetComponent<BoxCollider2D>();
    }

    void Update()
    {
        if (IsGrounded() && Input.GetKeyDown(KeyCode.Space))
        {
            rb.velocity = new Vector2(rb.velocity.x, JumpingHeight * Time.deltaTime);
            Debug.Log("Jumping");
        }
        HandleMovement();

    }

    private bool IsGrounded()
    {
        RaycastHit2D raycastHit2d = Physics2D.BoxCast(bc.bounds.center, bc.bounds.size, 0f, Vector2.down, 1f, platformsLayerMask);
        Debug.Log(raycastHit2d.collider);
        return raycastHit2d.collider != null;
    }

    void HandleMovement()
    {
        if (Input.GetKey(KeyCode.A))
        {
            rb.velocity = new Vector2(-MovementSpeed * Time.deltaTime, rb.velocity.y);
            Debug.Log("Going Left");
            transform.localScale = new Vector2(-1, 1);
        }
        else
        {
            if (Input.GetKey(KeyCode.D))
            {
                rb.velocity = new Vector2(+MovementSpeed * Time.deltaTime, rb.velocity.y);
                Debug.Log("Going Right");
                transform.localScale = new Vector2(1, 1);
            }
            else
            {
                //no keys pressed
                rb.velocity = new Vector2(0, rb.velocity.y);
                Debug.Log("No key pressed");
            }
        }
        if (rb.velocity.y < 0) //reponsive jumping and falling
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
        }
        else if (rb.velocity.y > 0 && Input.GetKeyDown(KeyCode.Space))
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }

    }

}


texts:
In academia worst case Big O is taught over everything else.  Compared to space complexity, normal case analysis, simplicity over complexity, etc.

In particular to game programming and industry, what really matters most and why?

References would be very helpful.


texts:
Possible Duplicate:
  Where to advertise my game?

Let's say I have developed a game and I want to "get it out there".  What I have in mind is open-source, non-commercial games.

What websites do you know of where you can promote your newly developed game, rather than simply posting it on your blog?


texts:
I'm making a Pong game and I'm just looking for a simple way to calculate a straight travelling path for the ball based on the angle of the ball. How would I go about implementing something like this? Here is my code right now:

public void UpdatePosition()
{
    //For now let's just implement a very primitive movement algorithm
    //TODO: Movement calculation based on angle of the ball
    ball.velocity = (ball.angle < Math.PI / 2) ? 5 : -5;
    ball.Point = new Point(ball.Point.X + ball.velocity, ball.Point.Y + ball.velocity2);

    //Check if the suggested point is beyond the boundaries of the window
    if (ball.Point.X > ball.view.Boundaries.Width || ball.Point.Y > ball.view.Boundaries.Height || ball.Point.X < 0
        || ball.Point.Y < 0)
    {
        ball.Collision(CollisionType.Boundary); // If it does raise collision event
    }

    //Check if the new point collides with the hitbox of a player paddle
    if (ball.gameController.Players[0].Paddle.GetHitbox().Any(point => point.Equals(ball.Point)) ||
        ball.gameController.Players[1].Paddle.GetHitbox().Any(point => point.Equals(ball.Point)))
    {
        ball.Collision(CollisionType.Paddle);
    }
}


texts: How can I add custom CSS to a Construct2 game?

texts:
I am making a simple game using Construct2. My problem is that Construct2 provides basic HTML buttons, but I want to put a background-image on my buttons.

To do that, I want to add custom CSS to my project. But I am not finding any option to add CSS to my project. I have added the CSS in my files directory, but it doesn't automatically work so there must be something else I need to do?


texts: Using DualShock 4 motion sensor in Unreal engine (windows)

texts: Anyone know how to access the gyro/accelerometer values from a DualShock 4 controller in the Unreal engine (under windows)? Are there any plugins that do this? Does raw input work?


texts:
I am currently developing a video game using my own game engine I develop at the same time. While making a good progress in the past months, I am currently stuck. I assume I only miss a minor thing, but I need another pair of eyes and I really hope you can help me!

I wrote a converter which reads FBX files (using the official FBX SDK 2017.0.1) and converts them into my own custom file format. I am able to read meshes, texture and material information, the skeleton and all animation stacks. In my game (engine) I am able to display the textured meshes and animate them with any of the read animation stacks.

However, there is one problem for me. I bought meshes for NPC characters from a 3D artist and I also bought a huge animation pack from another artist. The character meshes include the perfectly textured and rigged mesh with all joints and the animation pack contains a rigged dummy mesh with all joints and animations.

I want to be able to use any animation from the animation pack on any mesh from the character artist.

My first step was to write a joint mapper. When reading the files I know which joint has which type. So, I am able to map the joints from the character mesh to the animation mesh and vice versa. The skeletons of both meshes are pretty similar and the mapping is going to work out.

In the FBX samples the animation calculation for a given vertex is:

Inv(Mesh_GlobalPosition * Mesh_GeometryTransform) * Joint_GlobalPosition * Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix * Mesh_GeometryTransform

Since Mesh_GeometryTransform is the identity matrix for all files I have bought, I can remove it from the term above. The result is:

Inv(Mesh_GlobalPosition) * Joint_GlobalPosition * Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix

Joint_GlobalPosition is the transformation in Bone Space and the only matrix that is time-dependent in this equation. Inv(Joint_TransformLinkMatrix) * Joint_TransformMatrix is used to transform the World Space to the Bone Space, as I understood. Finally, Inv(Mesh_GlobalPosition) is used to transform the result back to World Space.

If I understood something wrong, please correct me!!!

The joints which are used for the animation mesh are in a different space than the joints from the character mesh, because they come from different artists. I believe the missing part is to map between the joint spaces of both meshes. However, I do not know where to enter the mapping and I also don't know which spaces do I need to map? Object Space? Bone Space?

I'd appreciate any kind of help and will reward a useable solution with credits in my game!


texts: If i make a game in Unity where a player can host their own servers, will it still cost me more money?

texts: I know that with Unity's networking system, you will have to pay Unity if you have more than X players on your servers at the same time.  I believe this is because that Unity is hosting the servers, and it costs them internet service?  But if the players are hosting their own servers, this wouldn't cost Unity any internet.  Is it possible to host your own servers using Unity networking, and if so, will it still cost extra money?  thanks. :)


texts: either use a for loop or iterator for the List of sprites for loop Optimization in libgdx

texts:
I am making and there I am making a frequent use of java.util.ArrayList for enemies, coins and shots. Is there any other utility in libgdx better than this from the Performance point of view.

Further, I can get my things done using a for loop too.So, Which would be better to use.
A FOR LOOP
or an ITERATOR


texts: Is there a way to get the time of an input event (a key or button press) to a higher degree of accuracy than the Update call, maybe by subscribing to input events and handling them immediately?


texts:
My game is played on a big spherical world. Made up of a big spherical mesh with sphere collider, with 'gravity' at it's center (gravity for objects is controlled trough scripts).

Now if I put a ball (spherical rigid-body) on there and push it, it will just go around as expected. But when I try to add an object with character-controller and move the character it will always stand as if the gravity is pointing up, and not at the center of the big sphere.

Since there is apparently no way to rotate the character-controller component (it's made for flat worlds) What are my options for controlling my characters on this spherical world?


texts:
While I realize there are many topics about CS vs software engineering vs game school programs, I haven't found anything relating to whether pure math degrees (with CS minor and electives) would also be a viable program. By this I mean: Would having a math major, CS minor put one at competitive disadvantage as compared to a pure CS program?

This relates specifically to game engine programming, more on the graphics side.

Background (for those who care): Currently a math major, CS minor at school and looking to land a career doing graphics engine programming. Admittedly, I love math and if at all possible would like to stay my current program as long as it doesn't put me at a competitive disadvantage trying to land a job post-graduation. That being said, I'm strong in the traditional C/C++ languages, strong concurrent programming skills, and currently produce self-made games for iOS. As an employer, how badly is the math major hurting me? Just want to get some advice from people already in the field!


texts: How do I prevent dynamic GUI elements from overlapping in Unity?

texts:
I'm working on a birds-eye-view for our Unity3D game world, where each point of interest has a label hovering above it. The problem is that sometimes they overlap, although there is more than enough space on the screen for them to co-exist.

Can anybody think of a better way to separate them than checking every texture with every other texture and moving them away from each other?


texts: How do I have a camera follow my object in Unity?

texts:
I have an object that automatically moves by itself and I want the main camera to automatically follow it.(Like in games such as geometry dash and jetpack joyride)
This is the code for the automatic moving object in case it is needed:

using UnityEngine;
using System.Collections;
public class automove : MonoBehaviour {
public static int movespeed = 5;
public Vector3 userDirection = Vector3.right;

public void Update()
{
    transform.Translate(userDirection * movespeed * Time.deltaTime);
}
}

So does anyone know any good scripts I could add to the main camera to follow this object that automatically moves? Thanks in advance!


texts: Game graphics taking too much memory of 0.5 GB

texts:
I am developing a simple 2D game. I have multiple sprites. Each sprite has around 80 png/frames of 265* 256. I used LibGdx's Texture packer to package the atlas. Am enabling mimap using following code to pac

    TexturePacker.Settings settings = new TexturePacker.Settings();
    settings.combineSubdirectories = true;
    settings.filterMin = Texture.TextureFilter.MipMapNearestLinear;
    settings.filterMag = Texture.TextureFilter.Linear;

    TexturePacker.process(settings, f.getPath(), outputFolderName, atlasFileName);

Questions:

Are 80 images/frames for single sprite too much?
Is 0.5 GB memory usage too much for a simple game like Fruit ninja?
How can i reduce my memory usage?
Any other things i should try?


texts:
I just wanna be straighforward. I read a dozen of articles talking about game loop, components, modules, structures, time control, etc...

But, in the end I'm still somewhat confused of how animation actually takes place in the game flow...

Explicitly: Each time the render() assumes command It may render (say) a player sprite (in 2D game). The player "animations" would be expanded in a spritesheet (?) and player object may hold it's state and frame. Say "running" frame 'n'. So the render will render that sprite.

Is that it?

If so, how should I control the actual frame when using a time based game loop (for fps control)?

How do I sinc that with the update variables (x and y position) of the player itself. That will mean that the character will "slide" until next frame (in a walking sequence)...?

Comments, pseudo-codes and maybe a link to a more deep-in article concerning these issue is appreciated... ;)

Thx,


texts:
I don't know if there is another term for it, but I mean this: You hold down a mouse button. A rectangle forms when you move the mouse around. The units inside the box get selected when you let go of the mouse button. I need this for a RTS style game I'm working on, but I don't know how to approach it.

I currently have functionality for selecting a unit, basically if you click within a certain area the unit is added to the list of selected units,

def mouseUp(self, button, pos):
    adjusted = self.coord_convert(pos)
    if button==1:
        for a in self.agent_list:
            if a.pos.get_distance(self.coord_convert_adjusted(pos)) < 16:
                self.selected.append(a)
            elif a in self.selected and a.pos.get_distance(self.coord_convert_adjusted(pos)) > 16:
                self.selected.remove(a)

The next step would be to allow for selecting multiple units at once by checking if they are inside a box, can you provide some guidance on how I should proceed?

Edit: To clarify, I'm asking how to create a box which starts at the position of MOUSEDOWN, and changes in size relative to mouse movement while holding the pressed button down, until let go.


texts: How do I implement a programming system in my game that is both accessible, powerful, and fast to code in?

texts:
I'm currently working on a space-based sandbox game which will heavily feature the ability to custom program your systems. I want to implement this in a way that is both

accessible,
powerful (bare minimum would be turing-completeness)
fast to code in.

Text-based languages generally only satisfy the latter two requirements, and while it's not to difficult to design a visual language which satisfies the first two, visual languages are a pain to program in due to requiring extensive mouse use. While there are some very accessible text-based languages, I want complete non-programmers to be able to ease themselves into programming.


texts:
I have added a few text boxes in my Unity game and they are at the bottom. When I fullscreen the game after building it, the text boxes show up in the right place but if I shrink the tab, the text boxes move and I don't want that. What can I do to fix that? I already have to move the text boxes way down to make sure they show up in fullscreen mode.
I am using Unity 2D.
In builder view:

In game view:

In full screen built view:

Steps I took to add text boxes:
I added the textboxes to the Canvas, added the scripts, and change the font color and style. I then just moved them to where I can see them but I realized that in different screen sizes, the text boxes move. I also changed the Display 1 ratio from "Free Aspect" to 16:9 but that didn't help either.


texts: What is the maximum value for a leaderboard entry in Google Play Services?

texts: What is the maximum value an entry in a leaderboard using the Google Play Services can have?


texts: Box2D: How can I speed up a physics simulation with many, many overlapping box bodies?

texts:
I'm new to physics libraries and am trying to use Box2D to help implement the procedure described in this article: http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php

(Edit for clarification:) The algorithm involves rectangular bodies of random dimensions being created in a random point in a circle. They are meant to intersect initially and have those intersections resolved by the simulation, so as to evenly distribute the bodies.

I've managed to get the algorithm working but it runs extremely slowly. Even with only sixty bodies to distribute, it takes over thirty seconds for all intersections to be solved and the bodies to return to sleep. For 120 bodies, it takes well over three minutes, which is horrendously slow.

The simulation progresses quickly when many bodies are overlapping, but slows down dramatically as the area becomes increasingly crowded with bodies. I suppose each body must have more work to do, in an abstract sense, to push an increasingly large number of bodies and interlocking rows of bodies out of the way.

I've tried making each body 0.00001f units in density (therefore lowering mass?), I've tried increasing the restitution value of each body and lowering the friction and linear damping values, but the simulation runs at about the same speed. Even multiplying the number of time steps, position iterations, and velocity iterations by ten doesn't seem to do anything.

So my question is, how can I tweak the simulation or each body's parameters as to greatly increase the speed at which every intersection will be solved? Accuracy of the simulation is no issue; I am subverting it anyway by rounding the coordinates to the nearest 32 px in the end.

Description of my physics bodies and fixtures:

b2BodyDef roomGenBody;
b2PolygonShape roomGenPolygonShape;
b2FixtureDef roomGenFixture;

roomGenBody.type = b2_dynamicBody;
roomGenBody.fixedRotation = true;
roomGenBody.linearDamping = 0.001f; // Seems to have no effect.
roomGenBody.allowSleep = true;

roomGenFixture.density = 0.00001;
roomGenFixture.restitution = 60.0f; // As far as I understand, more bouncy objects repel each other with greater force?
roomGenFixture.friction = 0.0f;

Concerning the world and running the simulation:

b2Vec2 physicsGravity(0.0f, 0.0f); // No gravity and at no angle.

float32 timeStep = 1.0f / 60.0f;  // Increasing timestep doesn't seem to have a very noticible effect.
int32 velocityIterations = 10;
int32 positionIterations = 8;

physics->Step(timeStep, velocityIterations, positionIterations);

Attached is an image describing my problem- Orange lines are the boundaries of my boxes, labelled 1-160:

Please let me know if any necessary information is missing. Thanks!


texts: How to make transitions between images in canvas (unity)

texts:
So I have 3 same images, but with different colors which I want to cycle in my menu. They are only with different hue/saturations and I want them to slowly reduce their alpha 1 by 1 so that the one behind pops up and then restart the cycle.

I'm trying to set a public image and reduce it's alpha, but it's not smooth.


texts:
On the left is a base mesh with armature in Blender. I imported this model and armature into Unity3d.

The result is on the right. The arms are clearly distorted, and I can't seem to fix it by rearranging the bone assignments.. It looks fine in Blender. Why is it doing this?


texts: Model mesh overlapping while animating in Unity but not in Blender

texts: I made an FPS model in blender and created reload animation when I imported that model in Unity I saw that while the magazine ejecting from the rifle it overlapped some of the gun parts. Then I went back to the blender and changed some keyframes and positions in the blender but in Unity, it showed me the same problem. I tried many times it looks fine in the blender but in the Unity, it has the same problem.


texts: How to SetActive or enable a Canvas attached to prefabs that get instantiated (tower defense style)?

texts:
I am back again after making much progress in quest for unity and c# knowledge. I have become stumped yet again by how to enable a canvas that is attached to my prefab. Here is the situation:

I am using C# on unity 5.5.0f3.

I have UI buttons that instantiate a defense based on a prefab. That prefab has a Canvas attached to it which has a health bar attached to it. Currently, the canvas is disabled so that the health bar does not show at all times. I am trying to make it appear only when I hold down a button, in this case "Z", and disappear when I release Z. My code is letting this work if I place a prefab before hand and set the GameObject reference in the editor. I want to get it to work for any object that has this canvas attached to it. This code does not work for all of the prefabs even if I take the canvas from the prefab and make it the reference.

I have tried to use an array like I have with other things that are currently working, but it does not work the same.

Here is my code:

public class DefenseHealthToggle : MonoBehaviour
{
public GameObject defenseHealthBars;
private bool isShowing;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Z))
    {
        isShowing = !isShowing;
        defenseHealthBars.SetActive(isShowing);
    }

    if (Input.GetKeyUp(KeyCode.Z))
    {
        isShowing = false;
        defenseHealthBars.SetActive(isShowing);
    }
}
}

While this is a minor detail in the game, I am trying to not let any of the ideas go if it is because I could just not figure out how to do it. I think I will learn the most if I don't give up every time I hit a wall and so far it has improved my knowledge tremendously! Anyone point me in the right direction or help me with some code? Thank you for your time!


texts: How to optimize collision detection in a lane-defense game?

texts:
Somebody told me that don't use the physical collision detection(don't use Collider,Rigidbody,Raycasting) because performance loss.instead of it use the mathematical way for collision detection.

Physical collision detection:

  Raycasting is a very useful and powerful tool available on the physics engine. It allows us to fire a ray on a certain direction with a certain length and it will let us know if it hit something. This however, is an expensive operation; its performance is highly influenced by the ray’s length and type of colliders on the scene.

in this game enemies randomly create in some points.is it that better instead of checking by Raycasting call the fire(); method(foreach plant in them row) when created zombies?

mathematical collision detection:

Vector3.Distance(a,b) is the same as (a-b).magnitude.

float dist = Vector3.Distance(other.position, transform.position);

is better checking distance than using mentioned components(Collider,Rigidbody).
he believes using Colliders and Rigidbody component produce lag in game.


texts: Need 3D RPG development library/framework recommendations

texts:
I’m currently planning to develop an RPG. It will be a project I do in my free time. No pres-sure behind it. I’ll probably be doing it together with a friend and it’s just supposed to be a fun project, something we just work on, if we like to. Although it is a private fun project, I will make arrangements for this project, like project management and detailed documentation etc. I will also have a look at this thread and gather more information before starting.

An important choice I have to make is what libraries or framework I want to develop the game with. I know that there isn’t a BEST library, but maybe someone with some experience can recommend a fitting library. Maybe I just write down what my “requirements” are.

C++
Offline RPG
Running on Windows will suffice
Therefore I tend do Direct3D, contradictions? Proposals? OpenGL?
Well documented API

If you need some more specific information, just tell me.

If you can recommend libraries, how is multithreading done in those? Are new threads created implicitly? I’d just like to know as much as possible about what is coming to me, before starting.

Thanks in advance!


texts: C++ Instantiating objects as function arguments / parameters (base and derived classes)

texts:
I've noticed with some functions in C++ that accept objects (e.g. constructors), you can actually create the object within the function argument e.g. (this example uses an SDL_Point as the main parameter)

//Constructor for custom object
object::object(SDL_Point spawn_location);

//Declaration of new object
SDL_Point new_point {0, 0};
object new_object(new_point);

//Alternatively, this also works
object new_object(SDL_Point{0, 0});

My question is, is this also possible with derived classes? My thinking behind this is that I have a single base class with a large number of derived (and derived derived etc) classes that I'd like to instantiate using a single function (to set various variables and add to a common vector). Current this looks like this:

void create_new_object(base_class object_to_create)
{
//Do new object stuff
}

This works:

my_derived_class new_object;
create_new_object(new_object);

However, I get an error (expected primary-expression before new_object) with this:

create_new_object(object new_object);

Is this strictly a base / derived class issue, a difference between functions and constructors, or is there something more I need to do to allow the function to accept the instantiation of objects within its parameters?

Thanks

Nathan


texts: How do you capture keyboard and mouse input for an HTML5 game?

texts: Is there an accepted method for capturing player input in HTML5 games? I have seen several methods, and the browsers seem to be in varying states of implementation; On MDN they tell you not to use both the newer and older implementations. I'm open to methods utilizing various libraries, but I would also like to see a pure JavaScript and DOM version as well.


texts: How can I prevent a follower from participating in fights in RPG Maker?

texts:
I'm developing a game with RPG Maker VX Ace. In this game, one of your followers is ghost-like demon that observes the player. I was going to have him appear during dialogues, but all of the playtesters were getting confused as he looks like the character the player interacts with.

I decided to make him a follower so it gets less confusing, but I don't think it would be interesting for him to participate in fights, as he would be too overpowered. I was able to prevent him from attacking, but not able to prevent him from being attacked.

How can I make this follow not participate in fighting at all?


texts: How to prevent images from being resized in game maker?

texts:
This warning appeared in the compilation menu of my game.

The images were rescaled in half. I understand that this happened because they had very large dimensions.

It turns out that the images, although they have a large size (pixels), are very light, because they are composed for the most part by simple traces in addition to having the transparent background.

Below, one of the images:

You see, it is very light.

It turns out that in the game it stops being clear.

How do I solve my problem? Using smaller images is out of the question.


texts: So I'm in the process of building a game in C++ for the engine and Python for behavior and moddability. One of the planned major features is that when the game client connects to a game server with mods, the server will tell the client where to get the mods. This introduces a security problem for the client as a mod with malicious code could be downloaded. How can I limit python so that mods can not affect the system outside of the game?


texts:
After using Monogame 3.3 with Xamarin Android, SoundEffect.Play method freezes the game. I try to convert wav files 8bit mono, 16bit mono no changes. This error on Samsung T101 android 4.0.3 but SoundEffects works with another android device which has 4.2.2.

I don't have this problem with Monogame 3.2. Any suggestion?

Thank you!

Android debug log below.

The thread 'Unknown' (0x4) has exited with code 0 (0x0).
Failed to generate OpenAL data buffer:
04-22 23:34:04.380 I/mono-stdout(10068): Failed to generate OpenAL data buffer:

Failed to get buffer bits: , format=Stereo16, size=73632, sampleRate=44100
04-22 23:34:04.380 I/mono-stdout(10068): Failed to get buffer bits: , format=Stereo16, size=73632, sampleRate=44100
04-22 23:34:04.390 D/Mono    (10068): DllImport searching in: 'openal32.dll' ('./libopenal32.so').
04-22 23:34:04.390 D/Mono    (10068): Searching for 'alDistanceModel'.
04-22 23:34:04.990 D/Mono    (10068): Image addref System.Runtime.Serialization[0x28084d0] -> System.Runtime.Serialization.dll[0x27ef090]: 1
04-22 23:34:04.990 D/Mono    (10068): Assembly System.Runtime.Serialization[0x28084d0] added to domain RootDomain, ref_count=1
04-22 23:34:04.990 D/Mono    (10068): AOT module 'System.Runtime.Serialization.dll.so' not found: Cannot load library: load_library[1091]: Library '/data/data/com.homemadegames.exterminator/lib/System.Runtime.Serialization.dll.so' not found
04-22 23:34:04.990 D/Mono    (10068): Assembly Ref addref MonoGame.Framework[0x1c80558] -> System.Runtime.Serialization[0x28084d0]: 2
04-22 23:34:04.990 D/Mono    (10068): Assembly Ref addref System.Runtime.Serialization[0x28084d0] -> mscorlib[0x1c66118]: 9
04-22 23:35:31.110 D/dalvikvm(10068): GC_CONCURRENT freed 159K, 5% free 8403K/8775K, paused 5ms+1ms
04-22 23:38:12.350 D/dalvikvm(10068): GC_CONCURRENT freed <1K, 2% free 8905K/9031K, paused 5ms+1ms


texts: Best way to add material to mesh map Unity

texts:
Ok bear with me because I don't know most of the terminology yet. I downloaded an asset for 2D tiling to use in my game so I'm basing this off the documentation terminology. It chunks my 1000x1000 map into chunks containing 10x10 Voxels that load as you move around. This works perfectly so I don't particularly want to mess with this. However since the textures are applied to the individual Voxels they don't look particularly good in a grid shape especially if animated. See below:

Is there any way to make this look better, either by syncing the animation between cells or applying the one texture to the whole block (although I suppose that will look the same just on a larger scale).

Chunk settings:

I'll upload any code/settings needed I'm just not sure what is pertinent, I've already tried tweaking most settings to little avail.


texts: How can I generate a navigation mesh for a tile grid?

texts:
I haven't actually started programming for this one yet, but I wanted to see how I would go about doing this anyway.

Say I have a grid of tiles, all of the same size, some traversable and some not. How would I go about creating a navigation mesh of polygons from this grid?

My idea was to take the non-traversable tiles out and extend lines from there edges to make polygons... that's all I have got so far. Any advice?