texts:
I want to make a little game in Unity, where the player (a ball) jumps up and down and you have to maneuver it through (flappy bird like) obstacles.

My problem is, after I added a simple movement script:

float speed 10f;
Vector3 move = new Vector3(Input.GetAxis ("Horizontal"), Input.GetAxis ("Vertical"), 0);
transform.position = move * speed * time.deltatime;

The ball is stuck and can only be moved a little,before returning to its start position.

My question is how i can fix that? I didnt find any solution


texts: Get speed from vector using box2d and javascript

texts:
I need to find the speed of an object in a game. The game is made in HTML5 with jquery and jquery.box2d.
For this I can use these methods:

 GetLinearVelocity().x;
 GetLinearVelocity().y;

I'm then trying to calculate the speed from this piece of code, but get some values that doesn't make sense when I console.log it. This is my code:

 var heroVelX = game.currentHero.GetLinearVelocity().x;
 var heroVelY = game.currentHero.GetLinearVelocity().y;

 var speed = Math.sqrt(heroVelX^2 + heroVelY^2);
 console.log(speed);

Some of the values in console.log are numbers, but most of them are NaN (Not-A-Number), which confuses me? Can someone help me solve this?

The goal I want to achieve, is to see when the speed(of object .currenHero) drop below a certain value, so I can excute a new state in the game.


texts: How to know the point of collision with another object in Unity5

texts:
I have a small problem and it would be very helpful, which could guide me. What happens is the following, I have an enemy (evil usb) in my scene, to the collisionar this enemy with my main player threw the enemy always right falling down the map. All right up here, what I need now is to know that exact point I'm colliding my enemy to know if I should throw it to the right or left depending on the point of collision which can be at the Centre to the right or to the left of my enemy like this imagen:

I read something about contact point, but can not understand how it works and really serves me, here is the code that I have to collision and throw it to the right:

void OnCollisionEnter(Collision other){

    if (other.gameObject.CompareTag ("Inacapin")) {
       enemyrigid.AddForce (-transform.right * 500, ForceMode.Acceleration); // work fine

      /*if(point of collision right){ // I need something like that

            enemyrigid.AddForce(-transform.right * 500, ForceMode.Acceleration);

         }else if(point of collision left){
            enemyrigid.AddForce(-transform.left* 500, ForceMode.Acceleration);
            }else{
             enemyrigid.AddForce(transform.forward* 500, ForceMode.Acceleration);
          }

     }

  }

hope they can help me, thank you... ;)


texts: Tiling texture doesn't repeat, even though wrap mode is set to repeat

texts:
For some reason, my floor tiling (set to 100 x 100) only shows on one corner of the plane. Past that corner, it just stretches out to the sides and leaves the middle one solid colour:

Here is how I've imported the texture (which was created by Jimmy Vegas:

And my material settings look like this:


texts: I made my first game in unity, and I was wondering if I can sell it without owing anything to unity?


texts:
I'm making a Flash game with ActionScript 3 and I have a square with a gradient applied to it. I am trying to programmatically changing the colour of the square depending on time, for example, some times it is orange, some times it is red, but it must always fade to black at the bottom.

The problem is, I'm using ColorTransform (as per here) but it seems to overwrite the gradient and simply fill the square with the solid colour. This isn't what I want. I want the colour that is chosen to fade to black at the bottom, like the original gradient.

How can I do this? Is there a way to only change the "hue" of the symbol (IE: not filling the entire thing with a solid colour), or will I have to reapply a gradient programmatically, with the desired colours?


texts: Securing feasibility in procedurally generated endless runner

texts:
I am currently in the concept phase for an endless runner I want to develop with libgdx in Java.

As I can not preassemble an infinite level, the generation of obstacles and power-ups needs to be "random" and during the game itself. In my last endless runner, I simply had randomness to determine the next obstacle type, as well as its position.

This time, however, I want to integrate two resources that play a major role and change the way I need to handle feasibility fundamentally.
One resource is some sort of an energy bar, which decreases over time, as well as due to collision with obstacles (possible to get over in the beginning, deadly as the game proceeds) and increases with the collection of power-ups.
The other resource is a coin-like entity, which you can collect during a run and which need to be present to a certain amount, in order to collect the energy-filling power-ups on collision.

I have a vague to solid idea of securing feasibility in terms of creating manageable obstacle-chains, but can't think of generation procedures, that ensure the possibility to collect enough power-ups while being provided the opportunity of collecting enough coins first. Furthermore, this procedure needs to increase the difficulty with the games duration.

I am not asking for code itself, but rather for adequate ways to approach my issue, such as dividing my endless runner in minilevels, that have some transition and are feasible on their own. Alternatively, experienced statements on which ways not to use and why are very welcome as well!

Feel free to ask further questions - Thanks in advance!


texts: What is "Avatar" in the "Animation Controller" used for?

texts:
I'm using animation layers for a model of type "Generic".
The "Base" layer contains an "Idle" animation.
The "Shooting Layer" contains a pistol shooting animation.
I want the shooting layer animation to only affect the upper body.
To do that, I need to use an Avatar Mask, I think.
In the avatar mask, I have to select if I want it to be of type "Humanoid" or of type "Generic".
I will not use a "Humanoid" avatar mask because my animations are perfectly tailored for my model, and I don't need any retargetting.
Instead, I wanted to use the "Transform" avatar mask type.
However, it seems to expect an avatar:

However, I haven't had the need to create one yet.
Do I really need to create an avatar?
I don't want any "Humanoid", I want to have full control over my animations and over what's going on. I have tried "Humanoid" before, and for me, it's a total loss of control as I can no longer tell what is a bug / mis-use by me and what is automatic retargetting done by Unity, so I want to avoid it by any means.
Why do I have to create an "avatar"? What is it actually?
Unity already has my generic model to work with, so it knows the transform.
Why does it want an "avatar"?
Edit:
The strange thing is: I can create an avatar the usual way -> "Rig -> Create Avatar" -> "From this model".
Then I have an avatar.
In the avatar mask, I need to feed an avatar. I do this, then it shows my transform. Now I can delete the avatar, and it still remembers my transform.
Strange... not sure why Unity can't simply use the transform.


texts: Creating an Android Game using Java and c++

texts: What's the best way to go about this? I've never coded using two languages before, let alone for an android phone


texts: How to find which side of a collider has been hit from hit.normal?

texts:
In Unity3D, I can get the normal of the surface with which the collider collides using hit.normal, but is there a way to find which side has been hit with what is provided by Unity3D?

One solution is to see the orientation of the normal, and should work well for static objects but what about dynamic and moving objects whose orientation changes?


texts: Is there a clean way in unreal to place text in the map to tag different buildings and areas for developper that can easily be turned on/off for all the tags in the map?


texts: Libgdx body passing through block then fall on it

texts: I'm using libgdx and its physic engine Box2d. My question is : how could I make my box2d body go through a block , ignore the first collison than make the block active so the ball can fall onto it. A good example is doodle jump.


texts: C# different resolutions compatible application

texts: Can you give me a quick tour for an application which has to work in different resolutions. It's a game, with lot's of graphics and images and effects. We are using C#. The game is simple 2D, looking like OGame but working like a desktop application. Our problem is how to make it compatible with different resolutions. What I expect you to give me is an advice - which technologies or combination of technologies and/or some basic tricks I should use to make my application work the same in different resolutions. Thank you!


texts: I've implemented instancing in my app and right now I have an instance buffer holding position data for all instances. But I'd like to also implement frustum culling which would cull some of the instances depending on the camera view. Now, how can I render only some of the instances in the buffer but not all? Do I have to rebuild the buffer every frame (so that it only holds visible instances) or is there a way in DirectX 11 to "tell" API which instances from the buffer I want drawn?


texts: Unity - Get list of gameobjects close to object clicked?

texts:
I have a stack of balls of 4 colors some touching some not. When you click on one color ball I want to destroy that ball and any other balls of that color that are close. They may not be touching so collision wont work.

How do I detect gameobjects close but not touching that are the same color? Say half a radius away from the edge of the ball clicked.

Here are the two scripts I'm working with to create and touch the game objects.

public class SpawnBalls : MonoBehaviour {
public Rigidbody ball;
public float waittime = 0.5f;

// Use this for initialization
void Start () {
    spawn ();
}

// Update is called once per frame
void Update () {
    //Instantiate (ball);

}
public void spawn(){
    //yield WaitForSeconds(waittime);

        for (var i = 0; i < 10; i++) {
            Instantiate (ball);
        }
}

}

Selecting the balls

public class Ball : MonoBehaviour {

public Color[] colors;
private Color ballpicked;

// Use this for initialization
void Start () {
    GetComponent<Renderer>().material.color = colors[Random.Range (0, 4)];
}

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

}
 void OnMouseDown(){
    if (Input.GetKey("mouse 0")){

        ballpicked = GetComponent<Renderer> ().material.color;

        //if (ballpicked == "Any other balls within a half a ball width") {

        //}

        Destroy (gameObject);
    }
}


texts: How can I avoid updating my Unity projects when I have two versions installed?

texts:
I currently have two versions of Unity on my Windows computer. I would like to not update my projects to avoid compatibility issues like I had in the past.

Installation in another folder goes just fine, but when I try to open Unity, it says that another Project is already opened and that if I want to continue I must update it. If I close this window, Unity aborts as well.

Is there a way to avoid this behaviour?


texts: Best way to have a body with 1 dimensional linear only movement in Box2D

texts:
I have a body that I am using as a paddle, it is expected to move in a vertical fashion and other objects should "bounce off it". The paddle itself should never move horizontally.

According to the docs this sounds like what I want...

  A kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to forces.

but reading further....

  Static bodies do not collide with other static or kinematic bodies.

So I create two Static Body lines and a box in between. How do I handle the box's movement? I don't think I want a dynamic object because I am only interested in linear moves (I.E. don't want wabbling).

What is the best way to handle this scenario?


texts: Explicit difficulty selection without breaking the game flow

texts:
According to the flow theory, in short, if the challenge is too hard, from flow state the player will go into an anxiety state, and if the challenge is too easy, he will go into a boredom state. This is fixed with dynamic difficulty, where a system tracks the player's performance and adjusts the difficulty.

But what about explicit difficulty selection which is often seen in shooters (Easy, Medium, Hard)? With such predefined difficulties, the challenge will always be either too easy or too hard, won't it? Therefore we cannot achieve a flow state, and following that, an immersion into the game is less likely. How do we fix this?


texts: Learning C++ but wanting to develop iOS Apps

texts:
I'm a computer engineering student and taking my second programming class. I'm learning C++ using "C++ Primer Plus" 5th edition by Prata. I want to develop for iOS. I understand the main language for Xcode is Objective-C. Am I hurting myself by learning C++ before any other language (notably before my desired lang Objective-C)? There's got to be a reason the university requires C++ to learn as a basis language.

Please offer any helpful guidance or how I should go about this. Thanks//


texts:
I am trying to completely unlimit the SFML framerate, so that as many frames will be displayed as possible. The reason for this is I want to loop through one section of code which calculates positions of objects in a physics simulation, and update the screen after perhaps 100 iterations.

I have done:

window.SetFramerateLimit(0);
window.UseVerticalSync(false);

The SFML documentation says this should set the frame rate to "infinity", but I still think it's stuck at about 60-ish...

Does anyone know how I can get more performance out of this?

Also once unlimited, I need to be able to do the equivalent of this in SFML, from SDL:

SDL.Delay(1000);

Is there a way of doing this? The SDL Delay is good because it frees CPU time for other processes. Any help would be greatly appreciated, especially as it's Christmas and you probably have better things to do! (I don't I'm a student.)


texts:
I'm building a visual novel and in one scene, I want to have a couple of different images move from one position to another and change size as it moves.

My first position is called "doorway", my second is called "left2".
Here's the code:

init:
    $ doorway = Transform(xpos = 0.34, xanchor = 0, ypos = 0.6, yanchor = 1.0, size = (100, 400))
    $ left2 = Transform(xpos = 0.4, xanchor = 0.5)

label room1:
    show room1

    show laura normal at doorway
    show laura normal at left2 with move
    hide laura with dissolve

    show annie normal at doorway with dissolve
    show annie normal at left2 with move

My problem is that when I run this, both laura and annie stay at (100, 400) size. I'd like them both to revert to their original size once I move them.

I wondered whether I could write size = (0.5, 0.5) instead of (100, 400) to halve them (this would work for my purposes) and then put size = (1.0, 1.0) in the left2 Transform declaration to bring them back to full-size, but that didn't work at all and actually didn't show their images whatsoever.

Is there a way to do it with relative sizing, or another way entirely? Thanks :)


texts:
I am rendering an FFT ocean using a quadTree. The T-junction problems seem to be eliminated but i am getting some weird pattern beween the edges of tiles of the same size as per the attached image. The same colour means that the tile has the same (world) size:

As you can see, the edges between tiles are quite noticeably distorted and will distort the textures on top.

I am using the following code to calculate the tesselation LOD (sphere LOD)

vec2 eyeToScreen(vec4 p)
{
    vec4 r = pMatrix * p;   // to clip space
    r.xy /= r.w;            // project
    r.xy = r.xy*0.5 + 0.5;  // to NDC
    r.xy *= Viewport;    // to pixels
    return r.xy;
}

float dlodSphere(vec4 p0, vec4 p1, float sideLength)
{
    vec4 center = 0.5 * (p0 + p1);
    vec4 view0 = vMatrix * center;
    vec4 view1 = view0;
    view1.x += sideLength;//distance(p0, p1);

    vec2 screen0 = eyeToScreen(view0);
    vec2 screen1 = eyeToScreen(view1);

    float d = distance(screen0, screen1);

    // triSize is desired pixels per tri edge
    float t = clamp(d / triSize, 2, 64);

    // Clamp to the nearest larger power of two.  Any power of two works; larger means that we don't lose detail.
    float logTess = ceil(log2(t));
    return pow(2, logTess);
}

If i change the tesselation to a fixed 64 it all looks okay so it has to be a problem in the Tesselation level calculated above. Anything that looks off in those functions?

EDIT 1:
I traced back the problem to a problem with the normals which get distorted at the edges. However it still doesn't explain why is undertesselating at some edges.

EDIT 2:
False alarm, when i get closer to the distorted area, it tesselates more and then distortion goes away


texts: How to instantiate new GameObject at position of old GameObject onAnimationComplete

texts:
I have a GameObject that is a Farmer that plants Seeds. The Seeds will animate into Plants. Once that animation is complete, I'd like to replace my Seed with a Plant. This happens hundreds of times per game at arbitrary positions. I've tried this as something I built off of this question: Unity: detect animation's end

public class SeedScript : StateMachineBehaviour {
[SerializeField] private GameObject seed;
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    Destroy(this);
    animator.GetComponent<TreeScript>().GrowTree(seed);
    Instantiate (tree, this.position,  this.rotation);
}

}

Obviously, this doesn't work at all. Doesn't even compile.

I've also looked at these co-routines: https://answers.unity.com/questions/981948/statemachinebehaviour-startcoroutine.html but again, I need to get position data from the animating object.

Yes, I could just merge my Seed and Plant classes together, let's pretend I cannot do that and MUST instantiate some arbitrary new object at the position of another object on some animation completion.


texts:
My game freezes randomly, mostly when changing from one level to the next. I cannot tell why this is the case. There are no errors or warnings. This happens when i build the game and when I am testing the game in the Unity editor. It will say unfreeze itself after a few seconds.  I have attached one of the level codes and the timer code. I have also attached a picture of how it looks when it freezes.
This is one of the level codes :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO.Ports;
public class Arduino5 : MonoBehaviour
{
    SerialPort sp = new SerialPort("\\\\.\\COM5", 9600);// Com port and the baud rate of the arduino
    Material m_Material;
    GameObject Sphere;

    void Awake()
    {
        Sphere = GameObject.FindWithTag("Player");
        m_Material = GameObject.FindWithTag("Player").GetComponent<Renderer>().material;
    }
    void Start()
    {
        if (!sp.IsOpen)
        { // If the erial port is not open
            sp.Open(); // Open
        }
        sp.ReadTimeout = 250; // Timeout for reading
    }

    // Update is called once per frame
    void Update()
    {
        if (sp.IsOpen)
        { // Check to see if the serial port is open
            try
            {
                string portreading = sp.ReadLine(); // get the string output of the serial port
                float amount = int.Parse(portreading);

                if ((amount > 50f) )
                {
                    m_Material.color = Color.grey;
                    Renderer _rend = Sphere.GetComponent<Renderer>();
                    Sphere.GetComponent<Renderer>().material = _rend.material;
                    _rend.material.mainTexture = Resources.Load("face4") as Texture;

                }
                else
                {
                    m_Material.color = Color.white;
                }
            }
            catch (System.Exception)
            {

            }
        }
    }
}

and this is the Timer code:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Timer : MonoBehaviour
{
    public int timeLeft = 5;
    public Text countdownText;

    // Use this for initialization
    void Start()
    {
        StartCoroutine("LoseTime");
    }

    // Update is called once per frame
    void Update()
    {
        countdownText.text = ("Time Left = " + timeLeft);

        if (timeLeft <= 0)
        {
            StopCoroutine("LoseTime");
            countdownText.text = "Times Up!";
            Invoke("ChangeLevel", 1.0f);
        }
    }

    IEnumerator LoseTime()
    {
        while (true)
        {
            yield return new WaitForSeconds(1);
            timeLeft--;
        }
    }
    void ChangeLevel()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}

In terms of trying to close the serial port, would something like this work:

void Start()

{
    if (!sp.IsOpen)
    { // If the erial port is not open
        sp.Open(); // Open
        sp.ReadTimeout = 250;
    }

// Timeout for reading
else if (sp != null)
{

    {
        sp.Close();
    }
}

}


texts: Set Sampler states: Linear, Bilinear, Trilinear Filtering/Interpolation

texts:
How do you set each of these sampler states in the hlsl

Linear filtering
Bilinear filtering
Trilinear filtering


texts:
Okay so i'm new to C# and i made this script. The goal i have in mind is that when the player is on the button and presses a button ( W in this case ) the button is switched from on to off ( or vice versa). The problem i have is that when the character stands on the button and presses W it doesn't always switch its state and i have no idea why. Any info would be appreciated.

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

public class Button : MonoBehaviour {
     public bool Pressed = false;
     Animator Anim;

     // Use this for initialization
     void Start () {
         Anim = GetComponent<Animator> ();
     }

     // Update is called once per frame
     void Update () {
         Anim.SetBool ("Pressed", Pressed);
     }
     void OnTriggerStay2D(Collider2D other){
        if (Input.GetKey(KeyCode.W)){
            if (Pressed){
                Pressed = false;
            } else {
                Pressed = true;
            }
        }
    }
}


texts: Copy the shortcut/hotkey to another project

texts: I modified my unity shortcut and later i found out that the new shortcut is not available in my new project i created.  it's only available in my previous project (where i created the shortcut). So how to copy this shortcut to other project ? Also i'm confused why the shortcut is project based ? not user based ?


texts:
I have stuck in a logical problem I have a third party package of DayNight. It takes hours input(24-hour-format) to show dayNight effects in scene

My code is to transform 12 hours clock cycle into 24 hours is

if (todsky.Cycle.Hour >= 0 && todsky.Cycle.Hour < 11.97)
            {
                Debug.LogError("1st");
                var degree = 360 - hourniddle.transform.eulerAngles.z;
                var degreeToMintues = degree * 2;       //multiply each degree with 2 to get correct minutes
                ConvertMinutesToHours(degreeToMintues); //
            }
            else if (todsky.Cycle.Hour > 11.97 && todsky.Cycle.Hour < 23.97)
            {
                Debug.LogError("2ndt");

                var degree = 360 - hourniddle.transform.eulerAngles.z; // as rotation is anti-clock getting rever degree
                var degreeToMintues = degree * 2; //multiply each degree with 2 to get correct minutes
                var MintuestTo24HoursMintueCoverstion = 720 + degreeToMintues; //add 720 mintues into current minute in order to get 24-hour-format
                ConvertMinutesToHours(MintuestTo24HoursMintueCoverstion);

            }
 void ConvertMinutesToHours(float mintues) {
        result = TimeSpan.FromMinutes(mintues);
        Debug.LogWarning(result.Hours + ":" + result.TotalHours + ":" + result.Minutes + ":" + result.TotalMinutes);
        todsky.Cycle.Hour = (float) result.TotalHours;
        Debug.LogWarning("setted hours : " + todsky.Cycle.Hour);
    }

But it is not working correctly .
 have made a clock GUI(360-degree) and as you know it only show 12 digits-format not 24. I am getting clock needle movement which can be change through mouse drag. Needle z position up to 320 degree which means one degree is equal to 2 minutes and i am taking it as input from GUI. I write below code to integrate my clock needle with my DayNight package in order to integrate GUI with package and passing hour parameter into the package but it not working correctly. Problem is that else condition is skipping.


texts: How can I implement 3D textures using webgl?

texts:
I went through the google I/O video but did not get exactly how to do it. If somebody could point me to a simple 3D texture implementation using webgl, it would be helpful.

i basically have a volume, a cube, i want to fill it up with pixel data, which comes from a stack of images along the x-y axis. How do i do that?


texts: How to hide fbx files for commercial release

texts: I see that all commercial games I've played never expose their fbx files - usually, they archive the fbx files into PAK file or BIN file. For example, Torchlight 2 use  OGRE3D for their Graphic Engine, and at the loading screen, they un-pack the PAK file. How do they do that?


texts: How to play a sound for a Game Jam Menu Template button in Unity

texts: I'm using the "Game Jam Menu Template" plugin from the asset store in a project of mine and I'm having a bit of a problem with it. See, I'd like it so that a particular button in the menu plays a sound before transitioning to the next scene. I've tried a number of ways to accomplish this so far, but none seem to be working. I initially tried attaching the AudioSource.Play method to the On Click () events for my button, but that didn't work. It seems that the StartOptions.StartButtonClicked method is interfering with the AudioSource's ability to play for some reason (that method is used to transition to the next scene in this plugin). So, I tried patching that function itself, by both running this.gameObject.GetComponent<AudioSource>.Play() at the beginning of it, as well as finding the object I wanted by tag and then attempting to play its AudioSource. However, both of these attempts at forcing the sound to play were unsuccessful as well and I'm kind of at a loss as to what to do now. Is there a way for a button that transitions to the next scene via StartOptions.StartButtonClicked to play an AudioSource before doing so in this "Game Jam Menu Template" plugin?


texts: How can I create an exclusive asset for multiple clients who all want basically the same thing?

texts:
This is more of a legal question than for example a coding question, but I hope that it's allowed as well. I recently started working as a freelance VFX Artist and do a lot of work with shaders and particle systems. Now, I am currently working on some dynamic shader, which creates cartoon-ish flames. I signed a contract with one of my clients, which states that I do not re-sell the work I did for them. But, I wonder what I should do when my next client gives me the exact same task and wants a dynamic cartoon fire shader, which is something almost every (cartoon) project needs at some point.

Would it be enough to just use a couple different nodes in Shader Graph, which would still basically do the same? Even then, let's say I get 5 more clients, who want the same from me. There are only so many variations I can do to the shader when the task was to make it dynamic. With particle systems I could just paint a different material and it would be a piece of art asset, but how does that translate to shader work?


texts: How do I change the gravity to just one object

texts: I'm making a 2d game on unity and I have a player who needs to walk on the four walls of a room, so I made him a rigidbody so it can change the gravity. But my game has enemies too and when the player changes the gravity the enemy is affected too (I just want them to move up/down in a pattern). How do I change the gravity to one specific object?


texts: Blender assets management and workflow for Unity project

texts:
I'm trying to decide how to manage my 3D assets, and even how I should construct a world for my game.

I should maybe explain, my game is basically a single explorable world set in a school. It's quite large. Every room and building enterable (possibly transitionless), and a large outdoor area (sports field, playground, etc.)
I plan to make much of it modular (walls, floors, etc.)
The world is somewhat tiled. I've create several different blocks for walls (Straight, cornered, T shaped, cross shaped, door, etc.) which I can place sequentially to create rooms and buildings.
I have some blocks lined up in a row in Blender. Now I'm wondering what to do with these pieces...

Issue 1)

Should I use Unity to place my assets to create my world, or do I create another blender file with all my assets linked?
I'm tending towards the latter because I feel I can do a lot more within Blender, but it doesn't appear very easy.
However in order for the game to function I'd imagine I'd have to cut up my world into pieces.
Problematically I'd also like to use Unity's terrain tool, so if I'm creating a single world object in Blender I'm not sure how I'd do this.

Issue 2)

I'm not very experienced in 3D game development, I've mainly worked with Flash up until recently.
In Flash, you can create movieclips which nest other movieclips. Preferablly I'd like a system as close to this as possible within Blender or Unity.

So for instance, I'd like to have a 3D asset of a table.
Without affecting the original asset, I want to place objects on the table like books and whatnot, and then control this as a single instance called 'Table with books', maybe duplicate it elsewhere, if I change the position of the books on one it should update all other instances.

In Blender, I use alt+D to duplicate an object and link it to the original, however it's very easy to duplicate an object without selecting it's children and creating a variety of differently childrened duplicates, which in a vast world which is hard to keep track of, would become a massive headache to deal with.
I can just imagine spending hours upon hours correcting a single silly mistake I produced and repeated without noticing for several days.

Within Blender I've tried making each wall object it's own group, however they're all in one file and have different xyz positions. I don't want to separate them into dfferent files, in order to create seamless walls I need to have them all in one place. When I create a group instance with shift+A, the origin is of the original group object's xyz position:

I know there's an offset option in the groups panel where I could set it to -2,4,0 to counteract this but I don't like this at all. If I move 10 original grouped objects I have to update each of their offsets! I suppose I could create an empty axis for each wall object, but this also seems an odd way of doing things.

Issue 3)

Walls are 2 sided objects, the design of one could be different on either side, one could be pink on one side with a skirting board, the other side could be exposed brick work. How would I do this?
Lets say I use Unity to position all my assets (which I'm now assuming is probably the right way), ideally I'd like to select a load of walls faces and change their design with a combo box of styles and a color picker in the inspector (a script would be necessary obviously).

Sorry, that's a lot of questions for a single post, I hope someone can point me in the right direction.


texts: Unity Additive particle effect blends with background

texts:
I created a fire particle effect with the Particles/Additive (Soft) shader in Unity 5.2.2, and it looks fine against a dark background, like the editor background:

However, when I move it in front of a lighter background, it looks like this:

I think the additive property is blending with the background, is there a workaround to make the effect look like how it looks on a dark background, without using a different shader?

I've looked at this question: How can I achieve a good fire effect with alpha blending and particles? but I'm not sure how I would execute that in Unity.


texts: Direct3D 12 STATE_CREATION ERROR #649: CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE

texts:
Every time my constant buffer helper creates the "Constant buffer view" with the CreateConstantBufferView method i get an error which states:

D3D12 ERROR: ID3D12Device::CreateConstantBufferView: pDesc->BufferLocation 0x00000000a9df6000 does not belong to any existing Resource or Heap. [ STATE_CREATION ERROR #649: CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE]

this makes no sense as the resource is created and used (just like in the previous working usages of this method) the only thing that is different is the descriptor heap and obviously the instance of the constant buffer helper.

Also it is used by a different command list and Pipeline state object (PSO), this may be the problem but I am unsure.

here is the relevant code for the creation of the constant buffer view:

D3D12_CONSTANT_BUFFER_VIEW_DESC desc = {};
desc.BufferLocation = cbvGpuAddress;
desc.SizeInBytes = size;
m_deviceResources->GetD3DDevice()->CreateConstantBufferView(&desc, cbvCpuHandle);
sizeInBytes = desc.SizeInBytes;

Below is for the creation of the descriptor heap and constant buffer helper:

 m_cbvSrvHeapManager = std::make_shared<DescriptorHeapManager>(DX::c_frameCount + 1, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, m_deviceResources);
    m_cbvDescriptorSize = m_cbvSrvHeapManager->GetDescriptorSize();

m_mvpConstantBufferManager = std::make_unique<ConstantBufferManager<Structures::ModelViewProjectionConstantBuffer>>(DX::c_frameCount, m_mvpConstantBufferManager->GetAlignedSize(), m_deviceResources, m_commandListManager);
    for (int n = 0; n < DX::c_frameCount; n++)
    {
        m_mvpConstantBufferManager->CreateBufferDesc(m_mvpConstantBufferManager->GetAlignedSize(), n, m_cbvSrvHeapManager, m_cbvDescriptorSize);

    }

Below is for the previous working usage of the creation of the descriptor heap and and constant buffer helper:

m_cbvSrvHeapManager = std::make_shared<DescriptorHeapManager>(DX::c_frameCount + 2, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, m_deviceResources);

m_cbvDescriptorSize = m_cbvSrvHeapManager->GetDescriptorSize();
    m_mvpConstantBufferManager = std::make_unique<ConstantBufferManager<Structures::ModelViewProjectionConstantBuffer>>(DX::c_frameCount, m_mvpConstantBufferManager->GetAlignedSize(), m_deviceResources, m_commandListManager);
for (int n = 0; n < DX::c_frameCount; n++)
{
    m_mvpConstantBufferManager->CreateBufferDesc(m_mvpConstantBufferManager->GetAlignedSize(), n + 2, m_cbvSrvHeapManager, m_cbvDescriptorSize);
}


texts: How would one go about gradually fading a sprite from one color to another?


texts:
I'm a bit of a novice to lighting, but I think what I want to do is possible, so please bear with me.

Due to the nature of my game, I've taken an approach where a singular scene game is where all of the gameplay occurs.

For each level, I'm arranging all the GameObjects and Terrain in a secondary scene (named testbed) to my liking. Once I've got it to my liking, I save that to a prefab, which in turn is saved to an AssetBundle. I also generate the lighting at this point, which I can see appear in my project under a Assets/Scenes/testbed/ folder.

At runtime, a script in the game scene reads the appropriate AssetBundle, and then loads & positions all of my objects and characters. Everything about this works, except for updating the lighting.

My approach is to store references to the lighting textures that have been output into the aforementioned testbed folder via a ScriptableObject (after trying and failing to use the LightingData object that appearred in this same folder):

Then, when I'm loading my level up into the game scene, this block is executed:

    public void LoadLighting(LevelKey key)
    {
        var data = levelMap.metaData.Find(it => it.key == key);
        var directions = data.lightData.directions;
        var lights = data.lightData.lights;

        var lightmaps = new LightmapData[directions.Length];
        for (int i = 0; i < directions.Length && i < lights.Length; i++)
        {
            var lightmapData = new LightmapData();
            lightmapData.lightmapDir = directions[i];
            lightmapData.lightmapColor = lights[i];

            lightmaps[i] = lightmapData;
        }

        LightmapSettings.lightmaps = lightmaps;
    }

Based on a lot of searching, this should cause something to happen, but I can't detect any change in the scene.

Does what I'm trying make any sense? Should I just scrap this and make dozens of different scenes (which I'm trying to avoid) instead? Really any advice here is appreciated.


texts: photon unity why error GO:Networking Manager appears when trying to make the scene not restart / reload when another clients join the room

texts:
photon unity why error
Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
appear
the code
 private void OnJoinedRoom()
{
    Debug.Log("OnJoinedRoom");
    PhotonNetwork.automaticallySyncScene = true;
    if (PhotonNetwork.isMasterClient)
    {
       GoToGame();
    }
    else
    {
        StartCoroutine(ReloaSceneCor());
    }
}

IEnumerator ReloaSceneCor()
{
    //send RPC to other clients to load my scene
  //  mainplayer.GetComponent<PlayerScript>().photonView.viewID = 1;  i added this but not working perfectly, it
    mainplayer.GetComponent<PlayerScript>().photonView.RPC("LoadMyScene", PhotonTargets.Others, "SampleScene");
    yield return null;
    PhotonNetwork.isMessageQueueRunning = false;
    //PhotonNetwork.LoadLevel(SceneManager.GetActiveScene().name); //restart the game
    PhotonNetwork.LoadLevel("SampleScene"); //restart the game
}
[PunRPC]
public void LoadMyScene(string sceneName)
{
    Debug.Log("REcieved RPC " + sceneName);
    PhotonNetwork.LoadLevel("SampleScene"); //restart the game
}


texts: Vertex Skinning Looks Messy on Real Android Device using Monodroid

texts:
I have no problem doing the "vertex skinning" for three-dimensional animation. All goes well when using the emulator (and genymotion). However, when run on a real device (such as Samsung and Lenovo) looks messy.

Screenshoot (Emulator)

Screenshoot (Real device)

Passing skin transform matrix

int location = ...;
int arrayCount = ...;
float[] skinTransform = ...;
GL.UniformMatrix4(location, arrayCount, false, skinTransform);

GLSL vertex

uniform mat4 World;
uniform mat4 View;
uniform mat4 Projection;
uniform mat4 Bones[20];

attribute vec4 Position;
attribute vec4 BoneIndices;
attribute vec4 BoneWeights;
attribute vec2 UV;
varying vec4 v_Position;
varying vec2 v_UV;

void main()
{
    mat4 skinTransform;
    int boneIndex = int(BoneIndices.x);
    skinTransform += Bones[boneIndex] * BoneWeights.x;
    boneIndex = int(BoneIndices.y);
    skinTransform += Bones[boneIndex] * BoneWeights.y;
    boneIndex = int(BoneIndices.z);
    skinTransform += Bones[boneIndex] * BoneWeights.z;
    boneIndex = int(BoneIndices.w);
    skinTransform += Bones[boneIndex] * BoneWeights.w;
    vec4 skinPos = Position * skinTransform;
    vec4 worldPosition = skinPos * World;
    vec4 viewPosition = worldPosition * View;
    v_Position = viewPosition * Projection;
    v_UV = UV;
    gl_Position = v_Position;
}

APK

http://1drv.ms/1BzYV3Q
Touch screen to on/off animation.

Info

Xamarin.Android = 4.10.x.x
Emulator Target = API 16 or 4.1
Real device Target = API 16 or 4.1
App Target = API 10 or 2.3 (tested also in API 14 and API 16), results remain the same

Is there any solution to solve this problem?

Best regards and thank you.


texts: How to prepare a rigged character model to be imported as a humanoid in unity?

texts:
I want to import a character as a humanoid to be able to use masks on animation system. I used proper human structure but unity gives some errors when I want to turn it from generic to humanoid and says some bones are not in the right place or have a wrong name.

The questions is how should a rigged model be prepared in modeling program to be imported in unity as humanoid?


texts:
My game has a bunch of GameObjects that I created with code at runtime and that I "store" in an array in a static class.

When I unload the scene and load it again, these objects are gone (of course). Is there a way to add the objects I store in the array back to the scene, so I don't have to create them again every time the player opens the options menu?

According to a bunch of old threads you weren't able to save a whole scene (including all of the scene objects and their locations) and restore it again later in Unity 5. Now that Unity 2017 is out, is that still the case or can you actually load previous scenes again (how would you do that)?


texts:
So let's say I have a tilemap 5 x 5, which equals 25 tiles.
How can I divide my tilemap into 25 different images? I'm using tiled, but I don't know if it is possible to do it on there or if I need to use one other program.
Of course, my tilemap is bigger than 5 x 5, so it's why I'm asking because it would consume a lot of my time.
Thanks.


texts: Perspective Projection Far Plane Not Clipping?

texts:
I've just discovered that far away objects in my world don't seem to clip like they should with a perspective projection matrix.

When I fly far away from my main landscape, so that I am much more than 10 units (if not hundreds) away, it won't disappear. This is weird, because I thought objects should clip/disappear once they hit the far plane.

Here's a photo that demonstrates the issue:

I have defined the projection with my own custom function. The field of view is 60 degrees and the aspect ratio is 1.3333 (although those shouldn't matter), the near plane is 0.1 and the far plane is 10. I have experimented with adjusting the far plane and even when it is 0.2 nothing is ever clipped. When it is 0.1 or below I get a blank screen. (which makes sense)

The matrix is calculated like so:

    projectionMatrix.setIdentity();

    float yScale = MathHelper.coTangent((float) Math.toRadians(fieldOfView / 2f));
    float xScale = yScale / aspectRatio;
    float frustumLength = farPlane - nearPlane;

    projectionMatrix.m00 = xScale;
    projectionMatrix.m11 = yScale;
    projectionMatrix.m22 = -((farPlane - nearPlane) / frustumLength);
    projectionMatrix.m23 = -1;
    projectionMatrix.m32 = -((2 * nearPlane * farPlane) / frustumLength);
    projectionMatrix.m33 = 0;

This produces a perspective projection like so:

    1.299038 0.0       0.0    0.0
    0.0      1.7320508 0.0    0.0
    0.0      0.0       -1.0   -0.20202021
    0.0      0.0       -1.0   0.0

Thanks very much if you could help with this annoying issue/benefit.


texts: How to avoid character to move when selected

texts:
I've got a player Class which can walk to a certain point on the screen when left mouse is pressed:

if (mState.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed)
            {

                    if (mState.X > CurrentPosition.X)
                    {
                        CurrentDirection = Direction.Right;
                    }
                    else if (mState.X < CurrentPosition.X)
                    {
                        CurrentDirection = Direction.Left;
                    }

                    CurrentDestination = new Vector2(mState.X, mState.Y);
                    CurrentState = PlayerState.Moving;
                    reachedDestination = false;
            }

Now I have several Characters on screen. If I want to select one of them I also do a left click, which sets the character to selected.

    if (mState.LeftButton == ButtonState.Released && oldMSstate.LeftButton == ButtonState.Pressed)
            {
                if (player1.BoundingBox.Contains(new Point(mState.X, mState.Y)))
                {
                    if (!player1.Selected)
                    {
                        player1.Selected = true;
                        player2.Selected = false;
                    }
                }
if (player2.BoundingBox.Contains(new Point(mState.X, mState.Y)))
                {
                    if (!player2.Selected)
                    {
                        player2.Selected = true;
                        player1.Selected = false;
                    }
                }
}

The problem is that as soon as one of the characters is selected it also performs the moving animation. This is beacuse for the trigger is the same for both moving to destination and selecting.

Do you know any way to avoid this behaviour and still keep using the left click for both?

Thanks in advance!


texts: What can I safely do with the MonoGame GraphicsDevice on multiple threads?

texts:
I'm working on a UI system that does it's processing on a separate thread. However, the results of this processing must end up on the GPU eventually.

A simplified overview of the system boils down to this step happening in the 'rendering phase':

Start at root widget (a widget is an object that controls what is rendered to the screen, and most importantly defines the hierarchical relation between controls).
Render widget to screen.
Iterate over all widget's children.
For each child go back to step 2.

When a widget is determined to be static (render output not changing over a period of time) the system must be able to choose to cache it in a texture in GPU memory (RenderTarget2D).

There are some other things that can be cached such as VertexBuffers and IndexBuffers.

Because the UI system does all its compution on a separate thead (to avoid slowing down the other game processes) I'm concerned about what methods I can call on anything other than the game's rendering thread.

Concrete questions:

What communication with the graphics device can be done from a separate thread?
If the above depends on the card or drivers, how can I determine whether it supports those actions?


texts: GameObject With Background Covers GameObject Without Background

texts:
so I have two sprites, a box and an X animation (I'm making Tic-Tac-Toe). So, in the code, when I click on the box, it instantiates the X animation at the right place. The X animation does not have a background, but the box does. However, when it instantiates, it puts it behind the box.

This doesn't make sense to me, but even when I move it around in the editor, moving it across the box puts it behind it. Which is interesting, since neither have layers. And even when I do put layers on (a higher layer on the X animation), it still goes behind. Take a look:

Any ideas on why this is happening, and how I can fix it?

EDIT: Here's my hierarchy and inspector:


texts: How can I import a model from a Source Engine game into Unreal Engine 4?

texts:
I am currently developing a game in Unreal Engine 4. This project is for personal use, and will not be exhibited or sold.

Because I have no talent, I need to snatch some models from some Source Engine games.

Does anyone happen to know how I would port these models into UE4?

I have Blender and Crowbar already installed.


texts: How can I prevent false score reports to global highscore tables?

texts:
Browser and mobile games commonly have global highscore tables. It's also common for those tables to contain scores of 2,147,483,647 — where people have figured out the webservice call that reports scores and used it to record a fictitious score.

For simple puzzle games, we can defend against this by including a record of every move the player made (and any random seeds used to generate the level) with the score-reporting call. The entire game can then be reproduced and verified on the server.

However, this quickly becomes infeasible for anything larger than Pac-man.

How else can cheating of this kind be prevented?


texts:
I have a pixel that have a colour RGB. This color is calculated by the shader and can be anything.

How can I override this color by a colour I choose. If my pixel is white it's simple, I can do this:

half3 original = half3(1, 1, 1);
half3 mycolor = half3(1, 0, 0);
half3 result = original * mycolor;

But what can I do if:

half3 original = half3(0.36, 0.74, 0.18);
half3 mycolor = half3(1, 0, 0);
half3 result = ?;

What operation or function should I apply to my original pixel color to override it ?


texts: Convert .s file to .midi or any sound file

texts:
I have a .s file from a game, I think it contains Music . I know this sounds weird but here are snippets :

(I opened it with Visual Studio and it sais it is a 'Assembler Source')

.equ    My_File_grp, voicegroup000
    .equ    My_File_pri, 0
    .equ    My_File_rev, 0
    .equ    My_File_mvl, 100
    .equ    My_File_key, 0
    .equ    My_File_tbs, 1
    .equ    My_File_exg, 0
    .equ    My_File_cmp, 1

The rest is only stuff like this:

@ 001   ----------------------------------------
    .byte       VOICE , 52
    .byte       N36   , An3
    .byte   W36
    .byte       VOICE , 58
    .byte       N48   , An3
    .byte   W48
    .byte       VOICE , 54
    .byte       N12   , Fs3
    .byte   W12

I need to listen to this but I really don't understand what these lines of code mean, please help! I want to convert this file to a file I can listen to.


texts: Unity - 2D Platformer Controller responsiveness issue

texts:
I've been designing some basic controls for a 2D platformer and managed to get the feeling that I've been looking for when moving and jumping, but something is not quite right, it's not very responsive.

Most of the inputs are detected, but a lot of times, for example, the simple action of pressing some key to jump is completely ignored and the player ends up falling when the key was pressed at the right time. I don't consider that I'm developing on a laptop with low specs at all if that matters.

Looking at some other questions it has always been said that input detection should be inside the Update function and that physics related stuff should be on FixedUpdate, however, it has not always been very clear what exactly should be on which function, as far as I understand it should go something like this...right?

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

public class PlayerController : MonoBehaviour {
    public float speed;
    public float jumpForce;
    public float groundCheckRadius;

    public Transform groundCheck;
    public LayerMask groundMask;

    private float direction;

    private bool facingRight;
    private bool shouldJump;
    private bool isGrounded;
    private bool shouldFall;

    private SpriteRenderer renderer;
    private Rigidbody2D rigidbody;

    void Awake() {
        this.renderer = GetComponent<SpriteRenderer>();
        this.rigidbody = GetComponent<Rigidbody2D>();
    }

    void Start () {
        this.facingRight = true;
        this.shouldJump = false;
        this.isGrounded = false;
        this.shouldFall = false;
    }

    void Update () {
        this.direction = Input.GetAxisRaw("Horizontal");
        this.isGrounded = Physics2D.OverlapCircle(this.groundCheck.position, this.groundCheckRadius, this.groundMask);
        this.shouldJump = Input.GetKeyDown(KeyCode.S) && this.isGrounded;

        if (this.facingRight && this.direction < 0 || !this.facingRight && this.direction > 0)
            this.Flip();

        if (Input.GetKeyUp(KeyCode.S) && this.rigidbody.velocity.y > 0)
            this.shouldFall = true;
    }

    void FixedUpdate() {
        Vector2 velocity = this.rigidbody.velocity;

        if (this.shouldFall) {
            velocity.y = 0f;
            this.shouldFall = false;
        }

        if (this.shouldJump)
            velocity.y = this.jumpForce;

        velocity.x = this.speed * this.direction;

        this.rigidbody.velocity = velocity;
    }

    private void Flip() {
        this.renderer.flipX = this.facingRight;
        this.facingRight = !this.facingRight;
    }
}

I'm not sure if I got the idea of Update vs FixedUpdate correctly because of this lack of responsive jumps, and I'm guessing that if I add some more mechanics, later on, those will react the same or worse.

Something that I noted is that if I move everything to update it now feels right every time I press the jump button, but I'm still not sure if that should be the right approach when building tight controls.

And I still feel lost about what everyone means by "You should manage physics in FixedUpdate", what do you mean by physics here?


texts: How to store information about a simulated sport match in a browser game?

texts:
There is a browser game called Soccerstar where users play in a soccer team and compete in matches against other teams. Matches are scheduled at specific times of the day and played automatically and when the user logs in he can watch an animation representing the last played match.

Now, I want to implement a similar feature: a match is simulated on the server based on the players statistics and tactical choices and the information about the match progression is stored in the database. Please note that I want the outcome of the players actions (tackles, shots etc.) not to be completely deterministic because I want to introduce some randomness.
Once the match has been simulated and stored, the client can retrieve the information and generate the animation at any time.

My main doubt is how to represent and store the information about the match progression: what would be the smartest way to do it?


texts:
I just wondered how to create a 3D effect similar to Pokemon White/Black? It seems to be not polygon based, but created just with sprites. If the perspective changes the sprites stay sharp and don't get blurred. How can I archive this?

Source: https://www.youtube.com/watch?v=fZEPUPYOnRc&feature=youtube_gdata_player

Edit: Wow, two downvotes because I used a video instead of screenshots? Don't get me wrong, I thank you, because you want to help me, but the 3D effect can be better understood in motion. Anyway, here is a screenshot: http://wearearcade.com/wp-content/uploads/2011/03/pokemon-black-white-starter-town.jpg

So, if this is a hardware limitation, how can I archive this o na different hardware, e.g. a HTML5 game?
Thank you.


texts: How can I full-screen a Facebook canvas game?

texts:
Is there any way to allow the user to click a button on a Facebook canvas app and allow the app to go full-screen?

If it's possible, is it permitted by Facebook?


texts: How can I set the radius the object will rotate around the target?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TargetBehaviour : MonoBehaviour
{
    // Add this script to Cube(2)
    [Header("Add your turret")]
    public GameObject Turret;//to get the position in worldspace to which this gameObject will rotate around.

    [Header("The axis by which it will rotate around")]
    public Vector3 axis;//by which axis it will rotate. x,y or z.

    [Header("Angle covered per update")]
    public float angle; //or the speed of rotation.

    public float upperLimit, lowerLimit, delay;// upperLimit & lowerLimit: heighest & lowest height;
    private float height, prevHeight, time;//height:height it is trying to reach(randomly generated); prevHeight:stores last value of height;delay in radomness;

    // Update is called once per frame
    void Update()
    {
        //Gets the position of your 'Turret' and rotates this gameObject around it by the 'axis' provided at speed 'angle' in degrees per update
        transform.RotateAround(Turret.transform.position, axis.normalized, angle);
        time += Time.deltaTime;
        //Sets value of 'height' randomly within 'upperLimit' & 'lowerLimit' after delay
        if (time > delay)
        {
            prevHeight = height;
            height = Random.Range(lowerLimit, upperLimit);
            time = 0;
        }
        //Mathf.Lerp changes height from 'prevHeight' to 'height' gradually (smooth transition)
        transform.position = new Vector3(transform.position.x, Mathf.Lerp(prevHeight, height, time), transform.position.z);
    }
}

Now it's rotating in a constant radius.
I set the variable axis to 0,1,0

But if I want the object to rotate around the turret very close to it or very far ? I want to add a radius variable so I can change and set the radius.


texts: Are there any resources about performance tweaks?

texts:
There are many optimization tricks that you can apply to your C++ code that can help speed up your program, and there are more game-related tweaks poping out every day. For example, I've just heard where you are trying to draw some meshes with same texture it's faster to draw them all in one call (or something like that which mean to pass texture once and for all of them).

Are there any books or weblogs or something which demonstrate these things? I'm working with C++ if there are any general advises about optimization, I'll be glad to hear about them.


texts: Draw textured circle / 2D shape in SceneKit

texts:
I have the following code to create a circle Path and a SCNShape from this path.  orbit_gradient.png is a horizontal 1px high image that represents a gradient.

let material = SCNMaterial()
material.isDoubleSided = true
material.lightingModel = .constant
material.diffuse.contents = UIImage(named: "art.scnassets/orbit_gradient.png")

let shapePath = Path.circle(radius: radius, segments: 512)

let orbitShape = SCNShape(shapePath)
orbitShape.materials = [material]
self.orbitNode.geometry = orbitShape

The problem I have is that when applying the texture to this geometry I'm just left with a white circle.  If I set the diffuse to be UIColor.red it displays as red.  What I want to accomplish is a stroked circle that appears to gradually fade, creating a rotating trail effect.


texts: PhysiJS and objects on top of moving objects

texts:
Using Physijs which uses ammo.js.

I am attempting to simply place a sphere on top of a box, the box is moving back and forth and I want the sphere to move with it while also being able to move on top of it.

I am already handling moving the object with setLinearVelocity but even with max friction the sphere doesn't "stick" to the box. I've tried increasing sphere velocity based on box speed but it doesn't seem to work.

Should this be working or am I on the wrong track? I've been stuck on this for quite a while and have tried every solution I can think of or find (and you can't find much on physijs). Perhaps I should try to get rid of Physijs entirely and just use ammo.js if I am trying to do these more advanced physics? (there will be much more to be added)

Hope my question is clear, and please let me know if you need code samples but it will be difficult to provide a good sample since my code is all modular and split up.


texts: How do I sort edge tiles for a hex grid in order to draw a border?

texts:
I am trying to sort the edge tiles of a region in my hexagon map. Once it is properly sorted, I can then try to walk through them and attempt at creating a Civ style border map, but I can't seem to figure out the sorting.
Right now I just have a simple line renderer that represents my results. Red portion of the gradient represents the start of the line.

It comes quite close at times.

I tried playing around with checking the direction I was coming from to change the neighbor sort, but haven't had any luck. I added a Stack so that I can walk back if I hit a dead end. Sometimes it works, but depends on the direction it was coming from.
Don't necessarily pay too much attention to the coordinates themselves. I've gone through the entire https://www.redblobgames.com/ docs and can easily convert from a 2D grid, to Unity's Offset, and to Cube coordinates. This particular code is initially the coordinates from a int[,] that was used in the procedural generation of the map.
public void CalculateEdgeTiles(ref int[,] regionMap)
{
    EdgeTiles = new HashSet<MapCoord>();
    if (Tiles == null)
        throw new Exception();

    MapCoord startingEdgeTile = null;

    foreach (var tile in Tiles)
    {
        foreach(var neighbor in tile.Position.ToHexOffsetCoordinateRing(1, true))
        {
            if (regionMap[neighbor.x, neighbor.y] != tile.RegionId)
            {
                EdgeTiles.Add(tile);
            }
        }
    }

    var sortedTiles = new List<MapCoord>();
    var queue = new Queue<MapCoord>();
    var stack = new Stack<MapCoord>();

    queue.Enqueue(EdgeTiles.First());

    var walkingBack = false;
    MapCoord previousTile = null;
    while (queue.Count > 0)
    {
        var currentTile = queue.Dequeue();
        if (sortedTiles.Contains(currentTile))
            continue;

        if (!walkingBack)
        {
            sortedTiles.Add(currentTile);
            stack.Push(currentTile);
        }

        var foundNeighbors = new List<MapCoord>();

        foreach (var neighbor in currentTile.Position.ToHexOffsetCoordinateRing(1, true))
        {
            var tile = Tiles.FirstOrDefault(x => x.Position == neighbor);
            if (tile == null || !EdgeTiles.Contains(tile) || sortedTiles.Contains(tile))
                continue;

            foundNeighbors.Add(tile);
        }

        if (previousTile == null)
            previousTile = currentTile;

        bool addedNeighbor = false;
        var neighborQuery = previousTile.Position.y < currentTile.Position.y
                                ? foundNeighbors.OrderByDescending(x => x.Position.x + x.Position.y)
                                : foundNeighbors.OrderBy(x => x.Position.x + x.Position.y);
        foreach (var neighborTile in neighborQuery)
        {
            addedNeighbor = true;
            queue.Enqueue(neighborTile);
            break;
        }

        walkingBack = false;
        //If we added nothing, pop the stack and start walking back to check the next neighbor.
        if (!addedNeighbor && EdgeTiles.Count != sortedTiles.Count)
        {
            walkingBack = true;
            queue.Enqueue(stack.Pop());
        }

        previousTile = currentTile;
    }

    EdgeTiles = new HashSet<MapCoord>(sortedTiles);
}

I'm hoping I am just missing a simple trick or I was just dumb on one section of the code. Any info is appreciated.


texts: How to achieve a Gaussian Blur effect for shadows in LWJGL/Slick2D?

texts:
I am currently trying to implement shadows into my game, and after a lot of searching in the interwebs I came to the conclusion that drawing hard edged shadows to a low resolution pass combined with a Gaussian blur effect would fit best and make a good compromise between performance and looks - even though theyre not 100% physically accurate.

Now my problem is, that I dont really know how to implement the Gaussian blur part. Its not  difficult to draw shadows to a low resolutions buffer image and then stretch it which makes it more smooth, but I need to add the Gaussian blur effect.

I have searched a lot on that and found some approachs for GLSL, some even here, but none of them really helped it.

My game is written in Java using Slick2D/LWJGL and I would appreciate any help or approaches for an algorithm or maybe even an existing library to achieve that effect.

Thanks for any help in advance.


texts: Which are the cons of using only non-member functions and POD?

texts:
I'm creating my own game engine. I've read these articles and this question about DOD and it was written to not use member functions and classes. I also heard some criticism to this idea.

I can write it using member functions or non-member functions it would be similar. So what are the benefits/cons of that approach or when the project grows, does any of these approaches give clearer and better manageable code?

With POD & non-member functions I don't have to make struct members public I can still use object id outside of engine like OpenGL does with all it's stuff, so It's not about encapsulation.

POD - plain old data

DOD - data oriented design


texts: Authentication for LAN Multiplayer Games

texts:
I'm working on the authentication scheme for a multiplayer game using only C++ and SLD2.

It's an RPG with a kind of complicated character-group/permadeath scheme, and world-instances are intended to be hosted by the players. So it matters that players have exclusive access to controlling their characters. I want players to be allowed to save the current state of a multiplayer world instance, close it, and come back to it later, or set up their own dedicated world instance for them and their friends to join/quit/rejoin at will. Absent player characters will simply not be present in the world until their creator returns

Servers will be hosted by player-computers. I'm not planning to set this up with a dedicated hole-punching or identity server, so players will just be playing with people who they intentionally connect to. I don't want to deal with encryption, so I'm not planning to require passwords to log in. I figure since there's no formal identity server and no encryption, passwords might do more harm than good. Player character names will change over the course of the game, and I don't necessarily mind if two players have the same username.

Here's my current authentication strategy:

When a player creates an account on his/her game instance, the account will just consist of a username and an automatically generated (random) UUID. The username and UUID will be stored in a SQLite file that the user can copy onto any computer with this game installed, and access their unique account. The username and a naively hashed UUID will be stored in a connection log on every server that the player connects to (so the server can assign them to the right character when they log back in). I recognize this means that programmers who know what they're doing will be able to hack each other's accounts, but I'm not convinced that I should really be concerned about that in the case of this particular game.

Here are my questions:

Is copying the file too much to expect from users who want to switch computers?
Can you guys think of any potential issues with this, other than what I've already pointed out?
Is there a better (common) way to achieve what I'm trying to do?

Thanks!


texts: Can i use the same name for a spell in my game that already exists in another game

texts:
what does trademarks and copyrights contain.
how similar can a name be to a name that already exists.


texts: Spawn chance, modulated by probability weighted by progress

texts:
I've been struggling with this for over a day now. What seemed a simple task, has just wrecked me. I hope someone here can help me figure out what I'm missing. Please, please help me :)

The functionality I need:

Think of my game as Guitar Hero, but instead of pre-placed nodes, I place the nodes randomly as the game progresses, at certain valid points in time. Now, instead of relying on randomness alone, I've made phases of difficulty, where I set a certain number of nodes to be spawned throughout the phase, and I'd like to have those evenly distributed within the phase. Since it's an arcade/highscore game, it needs to be roughly the same number of nodes placed every time you play the game, but the nodes should be placed differently each time. Until recently, I simply had something like this code, called for each valid point in time:

if(Random.Range(0f, 1f) < 0.25)
    // Spawn node

The problem:

Now I want to balance the number of nodes per phase. To do this, I have these variables:

TotalNodesToPut
NodesPut
NodesLeftToPut
PhaseProgress (0.0-1.0 normalized percentage of progress)

My plan was, to have the base chance of spawning a node to be 50%. I would then like to modulate that down to 0% and up to 100% depending on how many nodes still need to be put down, and how far we have progressed through the phase. It should be so that the percentage of nodes put down follows the progress percentage. If we have spawned 5 of 20 nodes (25%) but have progressed 75% of the phase, the chance to spawn a node should be really high. If we have spawned 15 of 20 nodes (75%) but have only progressed 25% of the phase, the chance to spawn a node should be really low.

It seems like a simple task, but I just can't get it to work :( I've tried dozens of things, started over again and again, and it's just never right, which is why I'm hesitant to show any code. I wouldn't want to start people off on the wrong foot. I have tried searching on the web, but haven't found anything about this particular problem. Any help is much appreciated!


texts: Calculation of a fight with many entities

texts:
User A can have many entities

A Entity is a object that has properties such as health, attack, defence, agility, stamina, etcetera.

When User A want to attack User B with x entities I am looking for the algorithm/equation to calculate the fight. I have brought some couple of ideas but they all have some pros and cons and I am not sure which one I would use or If I should use one of them at all?

Model A - The while loop
Basically I would get all the entities that is suppose to fight in this battle, I would assign each of them (objects) in to an array (the User A array and the User B array). Now I would simply loop through until one of the array is empty. Inside the loop I would let one of the User attack first, calculate the result (If the Entity has 0 health, remove it) and then let the next User attack back, calculate the result (If the Entity has 0 health, remove it) And then continue.

The Pros with Model A would be that every entity would be battling and instead of just do a calculation on all around there would be a justice fight.

The Cons To loop through like 10 entities would be fine but what about 1000-2000 entities? And how about the different strength of each entity I mean how could I decide which entity should battle against what entity? This could be just an sorted array (weakest > to strongest) But then I couldn't have like different types of entities is better against a different type of entity, meaning like a Gunner  wouldn't mean anything If it met a Swordsman even though a Gunner would most likely win such in a real fight.

Model B The idea of Model B is quite simple basically calculate all the attributes (properties) together and then If User A army has greater stats than User B army, User A army would win the fight. The Pros with this is it easy on the performance. The Cons are "Which entities would survive?" And it would basically be, the one with greatest army would win. You wouldn't even have a "chance" to win.

Model B B Then I started to think what If I take the concept of Model B  calculate the stat and then I have a battle between just those two single entities. This way User B actually would have a chance ( a small one but the possibility to win) even though the User A has greater army (better stats). The Cons are yet again, How would I know which entities that would survive on the winning team?

The answer I am looking for to this question is what Model should I use? And how would I solve the cons in that particular Model. Or should I use some completely different model (idea) ? (If possible please provide some php pseudo code)


texts: i need suggestion animation technique for 3d?

texts:
firstly you need to now i am beginner :)

i am using opengl and for display vertex buffer object(vbo).

i made 2000 frames animation model with blender and i export with (.obj) files and i upload all these 2000 obj files to my opengl project.

But upload process is taking too much time. like 7-8min and this method use too much vram around 2-3gb.

Despite all this i'm glad draw performance because when i draw 100 animation(same model) at the same time my pc using %1-2 cpu and %70-80gpu.

Now i want to learn is there another method of good draw performance and low system consumption ? (i want to draw 100 and much more animation model at the same time)


texts:
When making a 2D Pokémon game, I just faked elevation by putting mountain tiles underneath the land. Now my tiles are 3D models, so I'm using layer properties to define their elevation. What I don't know though is how to generate a 'mountain' around them.

The tilemap is kinda' like this:

Layer 1: Layer 2: Layer 3:
....     \\\\     \\\\
....     \..\     \\.\
....     \..\     \\\\
....     \\\\     \\\\

Layer 2 has y-offset set to 1, and Layer 3 has y-offset set to 2. All they do right now is float in the air. What I'm trying to do is render a mountain around them.


texts: How do I determine a good path for 2D artillery projectiles?

texts:
I'm building a little "tank wars" game (like this one).

I understand the math, and I am able to define a parabola from the launcher to the objective I want to reach. The parabola depends on the projectile's initial angle and velocity. I don't really know how to find a good path that "fits" in the screen most of the time.

As an example: I started with a velocity of 100 in a level I created and the projectile was sent far far away upwards and took a long time to hit the target. On the other hand I would like to add some obstacles to each level for example a wall between both tanks with a hole in the middle where projectiles must fly through to damage the other tank.

Questions:

To get a valid path that mainly stays on screen, I think I could play with the maximum height of the projectile. How do I relate angle/initial velocity to maximum given height?
How can I make the computer tank scan obstacles on screen and find a path to the player? (For example, a wall with a hole in the center between them.)


texts: Count number of Vertices in VertexBuffer in XNA 3.1

texts:
Where in XNA 4.0 one can go:

 myVertexBuffer.VertexCount;

What is the best way to count the number of vertices in 3.1 for a dynamic buffer (i.e. where I do not know the number of elements that could be therein). I have come up with:

myVertexBuffer.SizeInBytes / VertexPositionNormalTexture.SizeInBytes

Where my vertices are VertexPositionNormalTexture's, but is this the best way? (it will be called often in Draw()).


texts: How should I model an economy-based game in code?

texts:
I'd like to create an economy game based on an ancient civilization. I'm not sure how to design it. If I were working on a smaller game, like a copy of "Space Invaders," I'd have no problem structuring it like this:

Main Control Class
Graphics Class
Player Class
Enemy class

I don't understand how I'd do this for larger projects like my economy game. Do I create a country class that contains a bunch of towns? Do the towns contain a lot building class, most contain classes of people? Do I make a path finding class that the player can access to get around?


texts: How to calculate size of object depending of its height on the screen?

texts:
I am programming a mostly 2D game on Android (with Andengine), but the player is a bouncing ball (kinda in 3D).

I wanted to make the bouncing of the ball the most realistic possible, using quadrilic equations (http://www.mathopenref.com/quadraticexplorer.html).
So I know how to calculate the vertical height (z) of the ball, but I do not know, what size should the ball be, depending on its vertical height (z).

When the ball touches the ground, it should be 64px (width and height of the sprite), but if for example it is at 100px above ground, what should be the width and height of the displayed ball ? Is there an easy way to calculate it ?

Thanks

Game Dev noob.


texts: Purchasing a TV show adaptation rights, how does it work?

texts:
Basically, I was thinking about a game based on a TV show, just for fun, and ended up thinking "well, it's not like it can be made anyway". Or can it?

In the present situation, developing a game by myself/ourselves on my/our free time, and then using crowdfunding to purchase the rights is not that crazy, if the show is really popular... and the rights not too expensive.

Purchasing the rights of the whole show is obiously a sh!tload of money, but what about adaptation rights? What is the range of price it can be? Is it a percentage of the full rights? Does it depend on the kind of adaptation (novel vs. toy vs. game)?

ps: if it can help answer, I was thinking about a MLPFIM retro RPG. Please don't laugh at me.


texts: Displaying debug line in custom raytracer implementation

texts:
Not sure if I should post this here or on the Math forum, but I will try my luck.

Some background. I made my custom raytracer. The processing happens purely on the CPU for now, no GPU interaction whatsoever. It supports basic Phong shading and X levels of reflections.

I started fiddling with some ideas now and I realized that I need a way to display debug lines so that I could debug what I am doing, at least to some extent.

I thought of this solution:
Debug line is a constrained plane, which means that it is basically a rectangle, with pixels having their normal always facing the camera. The line is defined by a start point, magnitude, direction, and thickness. Based on these properties I should be able to calculate everything I need to get it displayed.

Below is some pseudocode for checking if my ray is intersecting this debug line.

Defined in the line initialization are:

startPosition (where the line starts)
magnitude (lenght of the line)
direction (line direction)
thickness (thickness of the line)

Code:

function isIntersecting(_originRay, _rayOrigin)

    ray = _originRay.Normalize(); // Ray coming from the camera
    spreadVector = direction.Cross(ray).Normalize(); // Vector showing the line width direction
    lineNormal = ray * (-1); // Debug line pixel always faces the camera directly

    // Plane intersection
    denominator = ray.Dot(lineNormal);
    if (denominator > 0) // Plane not visible
        return false;

    hitDistance = (startPosition - _rayOrigin).Dot(lineNormal) / denominator;
    hitPosition = _rayOrigin + (ray * hitDistance); // Get the intersection point in 3D space

    widthVector = spreadVector  * thickness;
    hitPositionTranslated = hitPosition - startPosition;

    if (hitPositionTranslated.Dot(widthVector) > widthVector.Length() || hitPositionTranslated.Dot(widthVector) < 0) // Ray hitting the plane outside the constrained area
        return false;

    // Code for checking height here - Not putting it cause width is not working at first place

    return true;

I get this when using pretty great width (should be ~100px), but it is thin - looks like the algorithm is not constraining the width correctly:

I am obviously doing something wrong here. Any kind of help would be much appreciated!


texts:
I've been looking for a book that takes a bottom-up approach for graphics programming. So something that starts with 2d filtering, maybe moving into normal mapping, then ambient occlusion, etc.

I ask because I've been lazy for the last few years in game development and always used an engine that handles this. I want to start writing some shaders for my games instead of relying on the cryptic ones that I've borrowed in the past. I think a very strong knowledge in this will help and I'm a bottom-up kind of learner so please help me out!

I know the GPU Gems series is great, but they seem to be more like a cookbook than a bottom-up approach that I want. You tend to get more scattered theory from cookbooks instead of building on theory from previous chapters.

EDIT: Preferably something you've read! I can search amazon for this, but it's hard to get a unbiased review that way.


texts: How do I make a game over screen like Temple Run or Subway Surfer?

texts:
When you die in one of these 2 games I took screenshots of (Temple Run and Subway Surfers), what exactly comes up to say "Game Over" and posts your score and all-time high score?

Is it a different scene that is loaded after you die and says "Game Over" and has all of your stats?

Is it some sort of UI element that is enabled and becomes visible after the player dies and then it says "Game Over" and shows your stats (Just like the Game Over lesson on the Unity Survival Shooter tutorial)?

Or is something else entirely that I have no idea of? I'd like to implement a similar feature.


texts: How to rotate object not from it's center point but from it's another point?

texts:
I am new in unity and I am developing a game where I want to rotate my object I try this code for it.

if(Input.GetMouseButton(0)){
        if(Input.GetMouseButtonDown(0)){
            LastMousePosition = Input.mousePosition;
        }
        else if(LastMousePosition.y> 112){
            Bow.Rotate(Vector3.up*(Input.mousePosition.y - LastMousePosition.y));
        }
        else if(LastMousePosition.y<112){
            Bow.Rotate(Vector3.down*(Input.mousePosition.y - LastMousePosition.y));
        }
        LastMousePosition = Input.mousePosition;
    }

It works fine for me but my object is rotate from It's center point and I want to rotate it from another point can any one help me with this?


texts: Should a bowling game use a 2d or a 3d physics engine?

texts:
I'm creating a bowling game in flash+as3. I'm new to physics engines, so, to start I've begun to learn Box2D since I've heard it's one of the most popular physics game engines.
Currently, I'm not sure if it's the best solution. I'm not sure even if I should use a 2D physics engine or if I should move to 3D physics engine.
As you can see in the attached screenshot of my game, the ball should move on the lane until it hits the pins. The game has some amount of 3D behavior.
Please advise.


texts: How to rotate model, around its own center?

texts:
I have a 3d Model that it wasn't made from the origin of the 3d program, lets say that it was built at (100, 100, 100), I know how to rotate a model, but around the model origin point, (0, 0, 0),  now how can I rotate the model around its own center? In this example the (100, 100, 100) so that instead of going around the origin point (like the earth around the sun) it will rotate around its own center (like the earth rotation around its center) so I can create an effect of the earth rotating around the sun and rotating around its own center.

Here's my code:

modelTransform = (Matrix.CreateScale(3f, 3f, 3f) * Matrix.CreateRotationX(rotation) * Matrix.CreateTranslation(myModel.Position));
effect.World = transform[mesh.ParentBone.Index] * modelTransform;

with this code my earth is rotating around the sun, but I have no idea how to rotate it around its own center.


texts: How do I leverage code and experience across alternate platforms?

texts:
I continually build complex engines and libraries within a single platform and technology, to allow me to build increasingly bigger and better games. How do I continue this when development crosses into different platforms? If I switch platforms, how do I leverage past code and experiences?

Games are hard to build. Big games are even harder to build. I've decided that to be able to make big games, I need to start building smaller games, and building up an asset base of code, assets such as graphics and sounds, tools, and most importantly, game engines. I can eventually get there, one game at a time.

Let me give an analogy. To build an MMO 3D RPG, I would approach this by building and releasing small games with increasingly more features. This could entail, for example:

A simple 2D game
A tile-based game
A game with RPG elements (items, equipment, monsters, battle)
A full-fledged RPG
A 3D RPG

The problem now is if I have to change platforms or tools; I don't know how to leverage past code-bases and experience to start with a mature product.

Right now, I'm writing Silverlight (FlatRedBall) games. Let's say I stick with this for ten years, and then suddenly decide to write a PlayStation 6 game, which is in an entirely different programming language.

Granted, I have ten years of game-development experience, and ten years of professional software development experience from my day job, to back me up. I would still like some way to transplant that 2D RPG engine into the new programming language, or else leverage it, somehow.

Is this even possible? What are my options?


texts: How to find the ideal path done inside a given shape in LibGDX?

texts:
I'm trying to make an android/libgdx game in which for every level you have a different shape as a png, and you have to drag your finger inside the shape and try to be as close as the ideal path created after the shape. At the end of the level the game will show you in a percentage how close you were from the ideal path.

My question is how can I find the ideal way that the player has to follow? Is there any function that i can use to find out the array of points created after the shape?

My problem is that the shape width is different along the way, so I can't use the pixels path. I already have an algorithm which gives me the array of points from the path of the player so I have to compare it with the ideal one.

If you have any ideas of any algorithm or functions that can help please let me know. Any answer will be helpful.


texts:
I'm working with some splines which define a path a character follows (you can see a gameplay video here to get a better understanding of what's going on: http://www.youtube.com/watch?v=BndobjOiZ6g). Basically the characters 'forward' look direction is set to the 'forward' direction of the spline and when players tilt their phone left and right the character is strafed along its 'right' coordinate.

The issue with this is (rather obviously) in performance, interpolating over a spline to find the nearest position and tangent relative to the player is an incredibly costly operation. To get by this I cache a finite number of positions in what I call 'SplineDetails', the class is as follows:

public class SplineDetails
{
    public SplineDetails()
    {
        Forward = Vector3.forward;
        Position = Vector3.one * float.MaxValue;
        Alpha = -1;
    }
    public float Alpha; // [0,1] measured along length of spline where 0 is the initial point and 1 is the end point of the spline
    public Vector3 Position; // the point of the spline at this alpha
    public Vector3 Forward; // the forward tangent of the spline at this alpha
}

I populate this with say 30 coordinates and I can give a rough estimate of a coordinate and 'forward' based on a position past in. It's not as accurate but it's much faster.

But now I'd like to make the system work better by estimating positions and 'forward' directions by interpolating between two of the cached points though I'm stuck trying to figure out some logic.

My first problem is, how can I determine between which two points the object is? Given each point can be placed at different intervals along the spline it could mean that two points in front or behind the object can be closer to the object.

The other problem is to figure out the proportion between the two paths it's between, i.e. if there is a point a at coordinate (0,0,0) and point b at coordinate (1,0,0) if the object is at position (0.5,0,0) then the result it should give is '0.5' (as it is equal distance away from point a and point b). That's a simple example, but what if the object is at coordinate (0.5,3,0) for example?


texts: What are typical job interview questions related to game development?

texts: I've already looked at some examples from StackOverflow, but I'd like to know if any of you could show concrete examples of job interview questions... Are they different with a job related to game development?


texts:
My progress so far: https://codepen.io/anon/pen/OjxLeO

Currently the player has only x and y coordinates.

I want to change that to vectors, like described in http://natureofcode.com/book/chapter-1-vectors/

Let's say the player should start at 12:00 and move clockwise 1 degree per second.

No clue how to implement it.

Any hints?


texts: How can I implement collision for a "pseudo-3D" game?

texts:
I'm looking for high level implementation details, not specifics.

I've worked with bounding boxes before in some 2D games, but I'm currently tackling a "2D + depth" (2.5D?) style game along the lines of Double Dragon, Battletoads, TMNT: The Arcade Game, etc and I'm curious what a sensible collision system would be.

I think collisions between actual game objects is, for the most part, okay. I'm basically using a bounding box test that only executes if the objects' positions are within some depth threshold of each other. My real question is about collisions between floors and walls.

I want more freedom with the floors and walls than those older games listed as examples, so I've also put "mesh objects" into the game that are essentially just planes defined as combinations of triangles (simple floors also exist). The mesh objects can be static or dynamic (ie, floating platforms), and are built out of arbitrary points (ie, they are not always flat and parallel with the floor).

I can mathematically calculate collisions between objects and meshes, but I'm not sure how to go about calculating collisions between meshes themselves.

For example, how can I calculate whether two arbitrary triangles made of three arbitrary 3D points collide on a turn given position, speed, and acceleration vectors for each?

If this system sounds clumsy, I'm open to suggestions :)


texts: Gravity/collision problems: models jumping

texts:
I'm pretty new to Unity3D game engine and game development, so don't judge me strictly. I import a model of the rail track, add rigid body component (with mass 1 and use gravity flag) and box collider component. Then I add train engine with rigid body (mass == 1, use gravity) and box collider and put it on the track. When I'm running simulation, train engine starts jumping like a ball (despite material for tracks and train is Metal (built-in Unity material)).

There is an important note that rail tracks are fixed (freeze position set in rigid body options). It seems to be natural. Anyway, if I turn off freeze position option then train engine does not jump, but tracks fly apart.

So I'm in trouble here. Can you please suggest what is the problem?

Thanks in advance.


texts: How to create a spiral brightness gradient

texts:
I am stuck on creating a brightness gradient that looks as below(the values are continuous from the inner circle). What formulae can create such brightness gradient? So that when _Time is added to it, it will slowly brighten up from the inner circle in a spiral form?

Tried a long time to modify from codes below but fail.
Shader "Unlit/testDisplay"
    {
      Properties
     {
        _MainTex ("Texture", 2D) = "white" {}
     }
    SubShader
    {
    // Render with transparent objects, after the opaque pass.
    Tags { "RenderType"="Transparent" "Queue"="Transparent"}
    LOD 100

    // Don't write to the depth buffer.
    ZWrite Off
    // Additive blending (add light/glow).
    Blend One One

    Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        #include "UnityCG.cginc"

        struct appdata
        {
            float4 vertex : POSITION;
            float2 uv : TEXCOORD0;
        };

        struct v2f
        {
            float2 uv : TEXCOORD0;
            float4 vertex : SV_POSITION;
        };

        sampler2D _MainTex;
        float4 _MainTex_ST;

        v2f vert (appdata v)
        {
            v2f o;
            o.vertex = UnityObjectToClipPos(v.vertex);
            // Shift our texture coordinates so 0 is in the center,
            // and we go to -2 ... +2 at the edges.
            o.uv = (v.uv -0.5f) *4.0f;
            return o;
        }

        fixed4 frag (v2f i) : SV_Target
        {
            //Define boundary value for radius
            float radius=length(i.uv);
           radius = radius - (radius % 0.5) + 0.5;

            //convert to polar coordinates
            float angle=atan2(i.uv.y,i.uv.x);
            float angle1=frac(angle/(2*3.142f));
            float result=-4*radius+angle1+13*frac(_Time.x);
            return result;

        }
        ENDCG
    }
}
}
```


texts: libgdx: SpriteBatch and ShapeRenderer projection wrong

texts:
I'm using LibGDX and the SpriteBatch and ShapeRenderer are having a perspective problem or something... When I draw something with both (code below), the planet texture is smaller than it should be. I can even manually set the size values and it's still wrong.

I'm setting:

    Matrix4 matrix = cam.combined;
    batch.setProjectionMatrix(matrix);
    sr.setProjectionMatrix(matrix);

and the draw code is...

            // outline
            sr.begin(ShapeRenderer.ShapeType.Filled);
            sr.setColor(Color.BLACK);
            sr.circle(c.getPos().x,c.getPos().y,c.getSize());
            sr.end();

            // planet tex
            batch.begin();
            batch.draw(c.getTexture(), c.getDrawPosition().x, c.getDrawPosition().y, c.getSize(), c.getSize());
            batch.draw(c.getShadow(), c.getDrawPosition().x, c.getDrawPosition().y, c.getSize(), c.getSize());
            batch.end();

Both the texture and the shape are centered properly and c.getSize() should always be returning the same value, so I'm trying to figure out why this isn't working. I've tried manually setting the value for size and it still does it, so either the texture is being rendered at the wrong size or somehow the ShapeRenderer and SpriteBatch are using a different camera/projection.


texts: How to communicate to an inventory item which character it's being used on?

texts:
Currently, I have an Inventory that is a ScriptableObject, which means it's not tied to any specific game object or player character. I just drag it into a MonoBehaviour if I would like expose the data of the inventory.

I have created an InventoryUI, which is a MonoBehaviour attached to a GameObject in my scene, and I assign the Inventory SO to it.

The InventoryUI contains button GameObjects with an InventorySlot script, to which I assign the item each slot is holding.

Everything works fine. When I click on one of the InventorySlot buttons, I'm able to call item methods, such as UseItem.

My problem is if the the item is a potion, for example. How can i add health to the player? Of course I could add reference to the player to the slot. But that will reference player repeatedly over 25 slots.


texts: How would I use an object from another animation in Unity?

texts: So I have two different .blend files with two different animations. Let's call my aiming with a gun animation animation A, and my other .blend file with idle, run, and jump animations animation B. If I wanted to play the aiming clip from animation A with the Animation B animator, it just looks like my character wants to shake hands, since the gun doesn't appear in the animation. The aiming animation works if I play animation A with animation A's animator. How would I use the gun object from animation A when playing animation A in animation B's animator?  Here is an image of what the animation looks like in the import settings (what i want) and in the actual game (what is happening which I don't want.) The top image is what I want and the bottom image is what is happening. Thanks in advance.


texts: Does Unity load the texture data of all the sprites in a sprite array property?

texts:
using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

    public Sprite[] mySprites;

}

From the editor, you can put sprites in the array property.

I want to put several large sprites there, like, 20 huge ones. However, only one of the 20 will be used by a SpriteRenderer at any given moment (I just have them in an array so I can switch easily in the future).

My concern is performance: does having an array containing 20 "Sprite" references imply that Unity will load the texture data of all 20 sprites? Or will Unity only load the data for the sprite that will be used by SpriteRenderer smartly?


texts: #pragma target 3.0 or 3.5? What is gained. What is lost for compatibility with older systems

texts:
I've just designed an image-based layering system shader. Multiple textures with Alphas overlay to create a fully dressed character, using 1 material.
pragma target 3.0 is where I had started (suggested default in UnityProjects).
After creating so many transparent-overlay layers in my code, I got this:
Shader error in 'Custom/Test': Too many texture interpolators would be used for ForwardBase pass (12 out of max 10)
The fix seems to be to upgrade to #pragma target 3.5
My game is going to be a Steam-distributed game, PC only.
What do I lose by using #pragma target 3.5? Will only super-dvanced PCs be compatible? Or should a fairly good/average PC be able to run this?
I don't know the intricacies of this subject.


texts: What does the hull shader attribute "patchsize" do?

texts: What does the hull shader attribute [patchsize(12)] do? MSDN fails to mention it. Do I have to use it? Should I use it?


texts:
I have a project that I'm having a bit of trouble with. Let me try and explain. In short, I'm trying to apply a texture to an object, but instead it is a solid color.

I built a building in "Autodesk 123d design", and exported it as stl. Then I used an online converter to convert it to obj, then added that to the unity scene. I created a material with a texture and tried to apply it to the object, but it was a solid color.

I think the UVs on the object might be messed up. I tried some things in blender, but had no luck. Any ideas on how I can fix this?

Edit:

Here is the 3D model I'm working with: http://www.123dapp.com/123D_Design/Conisbrough-Castle-Keep/4578568


texts: Rotating 3D Object Towards Swipe Direction

texts:
I have a character that has a constant speed, and I want to be able to change its direction with swipe gestures,
The exact same mechanism implemented here.
I managed to do that for movement only, without taking into account the rotation, but I want to create  this mechanism in such way that the rigidbody will have constant force in the transform.forward direction, and the Y rotation will change according to the swipe gestures, so the character will always move forward in local space, but will face towards different direction according to the assigned rotation.
I couldn't find a proper way of finding the desired rotation by the swipe direction.
How can I achieve this logic?