texts: Implementing a 2D Platformer Game Engine

texts:
Any ideas where I can find info about making 2D jump & run games? I need some general ideas, so I wouldn't reinvent wheel (at least where game design is concerned).

Another point is that I am thinking of using boxes instead of images for collision testing. However, it should possible that I can implement slopes. Commander Keen 4+ is a good example of my idea.

Actually, what is troubling me is of course the collision testing and simple physics (mainly gravity).

I've got to build the engine myself and it for the J2ME.

Thanks a lot, guys!


texts:
I am working on a simple 2D game in Java.

I want the game to have an opening screen, instructions screen, and the screen with the game itself.

From the opening screen the user presses buttons to get to the instructions screen or to the game screen. From the instructions the user should be able to get back to the opening screen. When a game is finished, the user is automatically sent back to the opening screen.

I want all of this to happen in the same JFrame. Each screen should be a class that extends JPanel.

What would be the best way to do that? I thought of making a method inside the Main class (the one with the main() method), the switches screens and can be called from anywhere in the program.

But how will this method switch screens? What would be the best way to replace the JPanels?

Thanks a lot


texts: How can I generate infinite boundary walls in PICO-8?

texts:
I have drawn one tile and I would like to use it in a very small shoot'em'up I am writing for fun and learning.
My aim would be to build something like Xenon 2 (vertical scrolling, a spaceship proceeding for a bit, at right and left walls that are programmatically generated so the ship can "travel" for a bit and then, in the end, meets final monster and end of the level) but I cannot think of how I can obtain this result without drawing everything manually in the map.

Not only code but also a good suggestion in topics / functions to study (all PICO-8 related, if possible) will be considered as a valid answer.

Here's a small manually generated example (walls are the grey blocks)


texts: Custom Pan/Tilt Input device and Unreal Gaming Engine

texts:
I have an augmented reality project I'm doing for a museum, using Unreal Engine. I've begun designing the controller (a pan and tilt visor you look through and move around). Originally, I was designing the input device to emulate a standard mouse output, but because it's augmented reality, will need really good absolute positioning. So I'm looking into absolute encoders for output- it needs to work as soon as you power on with no calibration required.

The question is two parts: if I start building my own input device which outputs discrete coordinates, rather than incremental x and y movement (as a traditional mouse controller chip does)
1) Can I get that data into Unreal Engine?
2) Can I control the camera rotation with that data?

The bigger question is- Is there a better way to do this? All I'm looking to do is build an Unreal Scene with a fixed virtual camera that is controlled by an external Pan/Tilt mechanism.

Many thanks for your input. Ha! Get it. Input.


texts: Is "forcing the user" to accept the terms an acceptable design in a smartphone/iPhone game?

texts:
I am about to release my first iPhone game, has been a long project and I involved several people. My lawyer strongly recommended me to add a "terms and conditions" page at the beginning of the app and to allow the user to continue to the game only if he presses "I agree".

In the iTunes game description I will include a link to the EULA and a warning saying "DISCLAIMER: The game will ask you to agree to the following EULA: HTTPLINK EULA.".

My main reason for adding this is that I got the license to use the name from relatively famous people and I need to put the terms and conditions in order to protect both my company and my licensee.

Some developers suggested me to avoid this strongly as I will lose user base. From my perspective I think that including terms and conditions is a fair thing to do and non-smartphones users are used to accept EULAs. It is true that on smartphones you rarely see this and can this really affect my game? Would you argue against my design choice to allow the user to play only if he accepts the EULA?

Are there among you any smartphone game developers that have had similar concerns and have asked their users to accept the EULA?


texts:
I wrote a simple script to control my 'Player' object:

using UnityEngine;
 using System.Collections;

 public class PlayerMovement : MonoBehaviour {

     public float jumpVelocity = 10;

     private Transform groundCheck;
     private Animator anim;
     private Rigidbody2D rigidbody2D;
     private bool grounded;
     private Physics2D gravity;

     [SerializeField] private LayerMask whatIsGround;

     const float groundedRadius = .2f;

     void Awake () {

         // Setting up references.
         groundCheck = transform.Find("GroundCheck");
         anim = GetComponent<Animator>();
         rigidbody2D = GetComponent<Rigidbody2D>();

     }

     // Use it for Graphic & Input
     void Update () {

     }

     //Physics and ground check
     void FixedUpdate () {

         grounded = false;

         Collider2D[] colliders = Physics2D.OverlapCircleAll(groundCheck.position, groundedRadius, whatIsGround);
         for (int i = 0; i < colliders.Length; i++)
         {
             if (colliders[i].gameObject != gameObject)
                 grounded = true;
         }

     }

     //Jump function
     public void Jump () {

         if (grounded)
             rigidbody2D.velocity = jumpVelocity * Vector2.up;
     }

     //Gliding function
     public void GlideON () {

         rigidbody2D.gravityScale = 1;
         Debug.Log ("Graviti is on");
     }

     public void GlideOFF () {

         rigidbody2D.gravityScale = 0;
         Debug.Log ("Graviti is off");

         if (!grounded) {
             rigidbody2D.velocity = ( -jumpVelocity / 10 ) * Vector2.up;
         }
     }

 }

To operate touch screen I used GUI function like this:

What I want to achieve:

One click - Player jump
Hold button - Player starts glide.
Player can not glide when he's grounded.
It does not matter whether I start from 'PointerClick' or 'PointerDown'. If player is grounded the first action should be 'Jump' always.
If we start with 'PointerDown', Player should jump and after reaching the maximum height he starts glide.
If we start with 'PointerClick' Player should jump.
If Player is not grounded and we want to start glide - we have to touch screen and hold it.

Where is the problem:

When I start with 'PointerDown', my Player begins infinite jump until 'PointerUp'.

I would be grateful for your help and suggestions.


texts: Why does Unity show dark regions on a model with animation created using Blender?

texts:
I sculpted a model in blender, and I want to import that to Unity. When I import just the model(without animation), Unity shows as is. However, when I attach armature to the body and automatically assign  weights to it with the intention of creating an animation, Unity import shows dark regions all over the model. All the face normals look fine. I am not sure what the issue is.
Model in Blender:

Weights:

Dark patches in Unity:


texts: Is there a way to display navmesh agent path in Unity?

texts:
I'm currently making a prototype for a game I plan to develop. As far as I did, I managed to set up the navigation mesh and my navmeshagents.

I would like to display the path they are following when setDestination() is fired.

I did some researches but didn't find anything about it.

EDIT 1 : So I instantiate an empty object with a LineRenderer and I have a line bewteen my agent and the destination. Still I've not all the points when the path has to avoid an obstacle. Furthermore, I wonder if the agent.path does reflect the real path that the agent take as I noticed that it actually follow a "smoothier" path.

Here is the code so far :

GameObject container = new GameObject();
container.transform.parent = agent.gameObject.transform;
LineRenderer ligne = container.AddComponent<LineRenderer>();
ligne.SetColors(Color.white,Color.white);
ligne.SetWidth(0.1f,0.1f);
//Get def material

ligne.gameObject.renderer.material.color = Color.white;
ligne.gameObject.renderer.material.shader = Shader.Find("Sprites/Default");
ligne.gameObject.AddComponent<LineScript>();
ligne.SetVertexCount(agent.path.corners.Length+1);
int i = 0;
foreach(Vector3 v in p.corners)
{
    ligne.SetPosition(i,v);
    //Debug.Log("position agent"+g.transform.position);
    //Debug.Log("position corner = "+v);
    i++;
}
ligne.SetPosition(p.corners.Length,agent.destination);
ligne.gameObject.tag = "ligne";

So How can I get the real coordinates my agent is going to walk throught ?


texts:
I am trying to create a shader in Unity that shows where intersections occur between objects.

Most of the shader I have so far is based off of this youtube tutorial. However, I have made some slight modifications to it. The main one being that it is only using a camera's depth texture instead of the depthnormal texture.

Shader "Intersection/Unlit"
{
    Properties
    {
        _Color("Color", Color) = (0,0,0,0)
        _GlowColor("Glow Color", Color) = (1, 1, 1, 1)
        _FadeLength("Fade Length", Range(0, 2)) = 0.15
    }
    SubShader
    {
        Blend SrcAlpha OneMinusSrcAlpha
        ZWrite On

        Tags
        {
            "RenderType" = "Transparent"
            "Queue" = "Transparent"
        }

        Pass
        {
            CGPROGRAM
            #pragma target 3.0
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float2 screenuv : TEXCOORD1;
                float4 vertex : SV_POSITION;
                float depth : DEPTH;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                o.screenuv = ((o.vertex.xy / o.vertex.w) + 1) / 2;
                o.screenuv.y = 1 - o.screenuv.y;
                o.depth = -UnityObjectToViewPos(v.vertex).z *_ProjectionParams.w;

                return o;
            }

            sampler2D _CameraDepthTexture;
            fixed4 _Color;
            fixed3 _GlowColor;
            float _FadeLength;

            fixed4 frag (v2f i) : SV_Target
            {
                float screenDepth = Linear01Depth(tex2D(_CameraDepthTexture, i.screenuv));
                float diff = screenDepth - i.depth;
                float intersect = 0;

                if(diff > 0)
                    intersect = 1 - smoothstep(0, _ProjectionParams.w * _FadeLength, diff);

                fixed4 glowColor = fixed4(lerp(_Color.rgb, _GlowColor, pow(intersect, 4)), 1);

                fixed4 col = _Color * _Color.a + glowColor;
                col.a = _Color.a;
                return col;
            }
            ENDCG
        }
    }
}

This shader produces a result that looks like this.

However, this is a problem as there are large areas of the object that remain the initial blue colour. What I was expecting was something that looked like this.

I think the issue is caused when calculating screen depth from i.screenuv

float screenDepth = Linear01Depth(tex2D(_CameraDepthTexture, i.screenuv));

I have tried removing the difference check, this initially appeared to work. Although, when I placed an object in front of the object with this shader, the shader behaved as if there was a collision when there was not. As you can see below.

I would appreciate any help in resolving the issue


texts: Amateur / Independent (m)MORPG Team management

texts:
I would like to ask you all a question about how I should be going about creating and especially maintaining an Amateur/Independent team for quite a big project.

I'm specially interested about common pitfalls like who to Not accept on a team for example but also any information about how to build and maintain a team of non (or very little) payed people for a project that might advance but slo(oo)wly.

Oh yes, before you downvote me for wanting to create a MMORPG, I already have created the game + server (up and running), coded the last 3 years by myself (ie. this is not a modified Ryzom or something likewise)

You can check it out here: www.mindoki.com

So now I'd love to build a team helping me out with things like creating talents, testing, making quests, taking care of the community, scripting, website (forum) etc. etc. etc.

For the story, a guy helped me for like 6 months creating a team doing graphics, plot and sound but not one of them was able to either follow a 'template' (using a texture set up and a pre made skeleton) or finish even Anything.

So how should I structure the "team", how should I recruit (should / must I handle all recruiting myself?) and what are the common caveats in such team management?

Thanks!

[EDIT]
I removed the edit, it messed up the initial question (which is 'What's the Do:s and Don't:s in amateur team management')


texts: Why do game studios need graphics programmers if they're using game engines?

texts: In the credits section of the games I play, there are names of graphics programmers. If they used a game engine, why do they need a graphics programmer? Isn't the game engine doing their job?


texts: 3d environments and managing them on iOS

texts:
I would like to start learning 3d game development and currently only develop 2d games.

A few basic questions I am interested in are:

What is used to create the 3d environments? Are they all done in e.g. Maya, Lightwave, 3d modeling software?

What is the output format for these models and how are they manipulated in iOS? Is it all done using openGL(GL ES on iOS)?

e.g a monster needs to be spawned in the game world. What coordinates are used?

Are the concepts the same as 2d in terms of collision on the coordinates and movement on the coordinates of the game world?

How are 3d games managed in iOS on the low available memory. (e.g. FPS games)

Lastly, Can someone please recommend a good book that is up to date and can be applied to todays techniques.

Thanks


texts: How to close an app correctly on desktop?

texts:
When I use Gdx.app.exit() the game window closes but the resources don't appear to be released and the app is still running.

For instance, to exit on when the escape key is pressed:

public boolean keyDown(int keycode) {

//...

    if (Gdx.input.isKeyPressed(Keys.ESCAPE))
        Gdx.app.exit();

The window closes, the dispose() method is called but Eclipse still reports that the app is open (because the terminate button is still available):

If the app had exited properly, the path to the JVM would have <terminated> in front of it, and the red terminate button would be greyed out.

Also when I use hide() and then dispose():

@Override
public void hide() {
    dispose();

}

@Override
public void dispose() {
    map.dispose();
    ...
    playerHitbox.dispose();
    System.out.println("----- END OF OUTPUT -----");

}

The same thing happens. You have to terminate the app with the button provided by Eclipse, or in the release version use the kill command (or task manager).

So my question is, how can I properly exit the app so all resources are gracefully unloaded, the window hides and the process exits in LibGDX?


texts:
I am probably asking a question answered here already; but I have yet to find the answer! Can anyone here help me with how updates work for your games? I know that through visual basic you can create batches to make shorter updates and everything like that but overall I am completely confused:/

How to get your game from Unity to Steam and how can you update the version and files efficiently?


texts:
I'm attempting to get my head around the XNA content pipeline, and how I can use it to simplify my game code. Specifically, I want to define sprites, sprite sheets, and animations as assets and have them automatically available to me in game code.

At the end of the day, this is what I want to be able to do:

add a new file with .sprite extension to my content project
call contentManager.Load<Sprite>("NameOfSprite"); and get back a Sprite instance

My Sprite class looks like this:

public class Sprite
{
    public Texture2D Texture
    {
        get { ... }
    }

    public Rectangle? SourceRectangle
    {
        get { ... }
    }

    public Vector2 Origin
    {
        get { ... }
    }
}

The purpose of the Origin property is not important - it's specific to my game. The point is, I want it to be "packaged up" alongside the texture information.

I've defined a SpriteData class as:

public sealed class SpriteData
{
    public string TextureFilename
    {
        get;
        set;
    }

    public Rectangle? SourceRectangle
    {
        get;
        set;
    }

    public Vector2 Origin
    {
        get;
        set;
    }
}

And I've added a test.sprite file to my content project as:

<?xml version="1.0" encoding="utf-8" ?>

<XnaContent xmlns:data="MyNamespace">
  <Asset Type="data:SpriteData">
    <TextureFilename>Sprites\Test.jpg</TextureFilename>
    <SourceRectangle>0 5 20 25</SourceRectangle>
    <Origin>30 2</Origin>
  </Asset>
</XnaContent>

I have defined a SpriteImporter as:

[ContentImporter(".sprite", DisplayName = "Sprite Importer", DefaultProcessor = "SpriteProcessor")]
public class SpriteImporter : ContentImporter<SpriteData>
{
    public override SpriteData Import(string filename, ContentImporterContext context)
    {
        using (var xmlReader = XmlReader.Create(filename))
        {
            return IntermediateSerializer.Deserialize<SpriteData>(xmlReader, filename);
        }
    }
}

And a SpriteProcessor as:

[ContentProcessor(DisplayName = "Sprite Processor")]
public class SpriteProcessor : ContentProcessor<SpriteData, SpriteData>
{
    public override SpriteData Process(SpriteData input, ContentProcessorContext context)
    {
        var spritePath = Path.GetDirectoryName(context.OutputFilename);
        var textureReference = new ExternalReference<Texture2DContent>(input.TextureFilename);

        // make sure the texture is built (not sure what else to do here)
        context.BuildAsset<Texture2DContent, Texture2DContent>(textureReference, string.Empty);

        return input;
    }
}

Now I'm stuck. If I don't implement a content writer+reader combination then I won't get a Sprite out of the content manager - I'll get a SpriteData instead, which is not what I want. But my attempt to implement a SpriteWriter came up short. I have no idea how to get the texture information from the processor to the writer. Do I need to change the type from SpriteData to something else? Is there a sample anywhere that demonstrates how to do this end-to-end?


texts: What free software can do this?  There's the Nvidia plugin for photoshop but I don't have photoshop :/.


texts: Native crashes on UE4 android game only in distribution build

texts:
As I build my game for development mode and install it directly from apk file to my device, it runs without errors and doesn't crash, there are in-game ads and it is able to get variables from game-saves.

But once I build with Shipping and Distribution tags and upload it to Google Play I get errors on all devices that it is tested. (Installing directly through apk also crashes it.)

Here are backtraces-

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'motorola/harpia/harpia:6.0.1/MPI24.241-2.35-1/1:user/release-keys'
Revision: 'p1b0'
ABI: 'arm'
pid: 14791, tid: 14855, name: Thread-932  >>> com.MadElectron.FarmPlanet <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    r0 00000000  r1 00000000  r2 00000001  r3 00000000
    r4 000084fa  r5 95bd3280  r6 00000000  r7 00002888
    r8 9dbb5fd4  r9 980edb20  sl 96d7f100  fp 9dbb5f88
    ip a274d504  sp 9dbb5f60  lr 9fd0eed4  pc a162ad24  cpsr 20070010
backtrace:
    #00 pc 0344dd24  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (_ZN22FSessionServicesModule13StartupModuleEv+72)
    #01 pc 01b32058  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (_ZN14FModuleManager27LoadModuleWithFailureReasonE5FNameR17EModuleLoadResultb+432)
    #02 pc 01b31e98  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (_ZN14FModuleManager10LoadModuleE5FNameb+76)
    #03 pc 0196bee8  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (_ZN11FEngineLoop4InitEv+1752)
    #04 pc 0196aa10  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (_Z11AndroidMainP11android_app+2568)
    #05 pc 0196e618  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so (android_main+108)
    #06 pc 01981bc8  /data/app/com.MadElectron.FarmPlanet-1/lib/arm/libUE4.so
    #07 pc 00041acb  /system/lib/libc.so (_ZL15__pthread_startPv+30)
    #08 pc 00019355  /system/lib/libc.so (__start_thread+6)


texts: Dealing with "jumping" sprites: badly centered?

texts:
Thing is, I've used darkFunction Editor as a way to get all the spriteCoordinates off a spriteSheet for each individual sprite, and parse the .xml it generates inside my game.
It all works fine, except when the sprites are all similarly sized, but when a sprite changes from a small sprite into a big one, such as here:

When from walking from some direction, to attacking, it starts "jumping", appearing glitchy, because it's not staying in the same correct position, only doing so for the right attacking sprite, due to the drawing being made from the lower left part of the rectangle.

I think someone experienced will immediately recognize the problem I mean, if not, when I return home soon, I will shoot a little youtube video demonstrating the issue!

So the question is: what possible solutions are there? I've thought that some sort of individual frame "offset" system might be the answer, or perhaps splitting, in this case, the sprite in 2: the sword, and the character itself, and draw sword according to character's facing, but that might be overly complex.
Another speculation would be that there might be some sort of method in LibGdx, the library I'm using, that allows me to change the drawing center (which I looked for and didn't find), so I could choose from where the drawing starts.


texts:
In the Unity Profiler, it says my meshes are taking over 200 mb memory. Thing is, I don’t have meshes in my scene. The only place they exist is in my list. Would that be it? Do prefabs on a list take memory?

I tried clearing the list, turning it to null, doing = new List. Yet they still exist in the profiler. My list derives from another class, which is serializable if that matters. Like List();

I hope I can get some help!


texts: Camera Sensitivity in PointerLockControls to match actual games

texts:
I am creating a FPS game online. I want the user to be able to use a sensitivity they are familiar with from games they've played. In this case, I want them to use their Fortnite sensitivity.

I am trying to figure out the Math behind it all.

I have figured out how to change the sensitivity in the PointerLockerControls.js file and can edit it from my main js file.

function onMouseMove( event ) {

    if ( scope.isLocked === false ) return;

    var movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
    var movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;

    euler.setFromQuaternion( camera.quaternion );

    this.speedFactorX = 0.002;
    this.speedFactorY = 0.002;

    euler.y -= movementX * scope.speedFactorX;
    euler.x -= movementY * scope.speedFactorY;

    euler.x = Math.max( - PI_2, Math.min( PI_2, euler.x ) );

    camera.quaternion.setFromEuler( euler );

}

I want to know what type of unit the '0.002' is.

In fortnite, I have my sensitivity at '0.08'. Obviously, this is way too fast to replace the speed factor values.

What kind of math do I need to match the users sensitivity in fortnite, to the speed factor values?

Hope someone can understand what I mean. Thanks!

This may help with the fortnite values - https://jscalc.io/calc/RTCJTLMts42GYfWf

I will be using the fortnite slider.


texts:
Im creating a 2d game for android.

I'll just get right to it. I have a sprite controlled by a joystick that needs to shoot, sofar Ive managed to get direction and movement on my bullet, but then I get stuck.

First of I need a delay for my bullet, cus right now its shooting like 10 bullets/sec, and you prolly know how that looks, like a beam of bullets.

Second there is a problem with the way I update the location for my bullet, my bullet position gets updated every time my sprite-position gets updated. This means that every time I move my character the previous bullets I've fired stop moving, so to be clear, the direction and speed of my bullet is fine, but the way it spawns and updates the old bullets when I move my sprite ( dragging gets set to true ) is really buggy. Maybe every element in my arraylist need a boolean for when its created?

Ill post some relevant code here:

Code for sprite/bullet positon, direction and speed:

    if (dragging) {

        // get the pos
        touchingPoint.x = (int) event.getX();
        touchingPoint.y = (int) event.getY();

        angle = Math.atan2(touchingPoint.y - inity,
                touchingPoint.x - initx) / (Math.PI / 180);
        spriteAngle = Math.atan2(touchingPoint.y - inity,
                touchingPoint.x - initx) / (Math.PI / 2) + 2;

        pointerPosition.y += Math.sin(angle * (Math.PI / 180))
                * (touchingPoint.y / 90);
        pointerPosition.x += Math.cos(angle * (Math.PI / 180))
                * (touchingPoint.y / 90);
        bulletPos.y = pointerPosition.y; //this is what messes up my bullet-position, if I move sprite, the existing bullets stop, so I cant move and shoot
        bulletPos.x = pointerPosition.x;

    if (event.getAction() == MotionEvent.ACTION_DOWN && (int) event.getX() > 650 && (int) event.getX() < 750
            && (int) event.getY() > 300 && (int) event.getY() < 400 ){
        shooting = true;

    }

    if(shooting){
        bulletPos.y += Math.sin(angle * (Math.PI / 180)) //!!!What I removed: * 5;
        bulletPos.x += Math.cos(angle * (Math.PI / 180)) //!!! here to: * 5;
    }

Code for drawing my bullet:

    private void shootingControl(Canvas canvas){ //is called in drawing-method
    if(controls.getShooting() == true){
         bullets.add(new Bullets(bullet, controls.bulletPos.x, controls.bulletPos.y));
         }

    for(int i = 0; i < bullets.size(); i++){
     bullets.get(i).update(); //!!!!added this
        bullets.get(i).draw(canvas);
    }

}

Code for bullet-class:

    public Bullets(Bitmap bitmap, int x, int y) {
    this.bitmap=bitmap;
    this.X=x;
    this.Y=y;
}

    //!!!What I tried adding!!!
    public void update(){
    X *=5;
    Y *=5;

public void draw(Canvas canvas){
    canvas.drawBitmap(bitmap, X, Y, null);
}

I've gotten some help from here alrdy regarding some of this, and I kinda feel bad for asking again, but I cant find anything anywhere and I cant figure it out on my own, really tired of being stuck here.

Ive seen some people using gametime in their bullet-positions and alot of people use vectors.
Or if you can redirect me to a good tutorial. I just want to get past this stage of my game!

Thank you!


texts: How to fix double click problem in this code?

texts:
Please see the gif below to better understand what's going on.

On first click they all work normally but after first click I have to double click them to select them. I'm not a advanced developer so I've been trying to figure this out for straight 2 hours and last choice I wanted to ask you guys.

I declared select effect here. (White circle) And added an Array to get all select effects.

    public GameObject selectEffect;
    private bool isSelected = false;
    public GameObject[] selectEffectArray;

I put them inside the Array.

    private void Awake()
    {
        selectEffectArray = GameObject.FindGameObjectsWithTag("planetSelected");
        selectEffect = transform.Find("selectEffect").gameObject;
    }

I deactivate all select effects on start.

    void Start()
    {
        Deactivate();
    }

Here's Deactivate code.

    void Deactivate()
    {
        foreach (GameObject effect in selectEffectArray)
        {
            effect.SetActive(false);
        }
    }

When I click one of the planets these happens. (I'm a little confused so I hope you can understand it.)

    void OnMouseUp()
    {
        if (isSelected)
        {
            selectEffect.SetActive(false);
            travelbutton.SetActive(false);
            isSelected = false;
        }
        else
        {
            Deactivate();

            planetName_text.text = planet.name;
            requiredFuel_text.text = planet.requiredFuel.ToString();
            travelbutton.SetActive(true);
            selectEffect.SetActive(true);
            isSelected = true;
        }

    }

I don't want to double click a planet to select it.


texts:
I have a number of Daz 3D models that I would like to use in my Unity shooter game. The only problem seemed to be the high poly count of the Daz models.

However, I just came across the Cruncher Polyreduction tool (http://assetstore.unity3d.com/#/content/4294). Is it possible to use this plugin to incorporate Daz models in my game?


texts: Calculate intersection of a line with a plane

texts:
I was reading something about: “Intersection of a line with a plane”. But I don’t fully understand how to calculate it on their way.

The goal is to calculate where the plane and the line will “cross”. These items are given:

The eye is in position: O(0,0,-10)
A point of a 3D-object is P(10,20,30)
The screen has the equation z=0

I have a questions about how they calculate this:

This part is clear. That is the location form the eye (vector representation).

They specify the location of the plane, there is nothing strange here (vector representation).

Now they calculate what part of the line will cross, how did they calculate this? How did they know a = 1/4? And b = 10/4?

This is everything that was given.


texts:
I render everything in my game in 2D with SpriteBatch with the exception of a spherical entity (orb) that I render as a spinning and dynamically lit (custom effect) sphere in 3D. I capture the sphere into a RenderTarget every frame and then use the image in the SpriteBatch to render in 2D. The composed image is aliased as any model.

I do not enable MSAA because various platforms that my game runs on (WinRT, as an example) do not support it. I tried FXAA as a custom effect, but the problem is that it does not appear to support transparency (I render the sphere on a transparent background).

My rudimentary solution is to render the sphere into a RenderTarget of size X and then render the result with SpriteBatch into a RenderTarget of size X/2. I set the SamplerState for the SpriteBatch draw call for the half size rendering to anisotropic, although I am not 100% sure this increases the quality of the final output dramatically (and at what cost?).

This solution appears to work fine but is not without its flaws. Mobile devices are slowed down by the multiple SetRenderTarget calls per frame, especially since I render more than one orb type.

Are there other approaching to this?


texts:
I added a sky to my raytracer that gets sampled when a ray completely misses any object.

What I'm doing here is if a ray completely misses anything in the scene, it returns the Perlin noise function at (ray.direction.x, ray.direction.y, ray.direction.z) - in other words it "samples a sphere around the origin".

But it "looks wrong" (because the sky looks like it's facing you).

How can I improve the sky and make it look more like the earth's horizon?

Or is this more or less what it should look like, and I should simply add more geometry on the floor?


texts: Unity: Moving on global X and Z axes with respect to local Y rotation

texts:
I'm having a bit of trouble with the math on this.

I'm trying to move an object forward based on it's local yaw.  Ordinarily, I'd just move it forward on the Z axis locally:

body.velocity = transform.TransformDirection (new Vector3 (0f, 0f, forward_velocity));

However, I need it to ignore the object's pitch and roll.  I don't want the Y coordinates to change.  It needs to move forward flatly across the X/Z plane based on its Y rotation only, even if its X and Z rotations are non-zero.

I tried doing this the way I would do it in 2D (by calculating how far it would need to move on X and Z separately), but the results are completely wrong.  The object moves on the x/z plane, but only along a single path, regardless of it's yaw.

Vector3 rotation = transform.rotation.eulerAngles;
float global_x_speed = forward_speed * Mathf.Cos (rotation.y);
float global_z_speed = forward_speed * Mathf.Sin (rotation.y);
body.velocity = new Vector3 (global_x_speed, forward_velocity, global_z_speed);

I tweaked some of these values, thinking I'd made a small mistake (swapping sine and cosine, using body.transform instead of transform), but I only got different weird results.

The last thought I had was that I could move it forward on the local Z and then reposition the Y coordinate to what it was before the translation, but I think that would result in both strange movement speed and strange clipping.


texts: Why does the object spawns only on client?

texts:
In my game I have an object, let say food, that whoever consumes it, that player will spawn one more element. I am checking collision in Update.
The following code is working fine on server side, but the object is not spawning. Although, it is spawning on local client but it is not updating on server.
Here is my code:
// This function is called on Update
private void CheckForFood(Vector3 snakePartPosToBeInitialize,Vector3 headPos)
{
    if(_food != null)
    {
        if (_food.transform.position == headPos)
        {
            UiControllerCS.UI.showScore();
            GameObject obj = Instantiate(snakePart, snakePartPosToBeInitialize, Quaternion.identity) as GameObject;
            currPartOfSnake += 1;
            obj.name = "" + currPartOfSnake;
            obj.transform.parent = gameObject.transform;
            tail.Add(obj);
            NetworkServer.SpawnWithClientAuthority(obj , connectionToClient);
        }
    }
}

I am getting the following error :

SpawnObject for 1 (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server.


texts: How can I manipulate a layer with click and drag functionality?

texts:
This works well on clicking layers but not click and dragging layers.
public class FishClicker : MonoBehaviour {

public LayerMask whatIsFish;

public float clickRadius = 0.1f;

void Update() {

    if (Input.GetMouseButtonDown(0)) {
        var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        var hit = Physics2D.OverlapCircle(mousePos, clickRadius, whatIsFish);

        if (hit != null) {
            var fish = hit.GetComponentInParent<Fish>();

            if (fish != null) { fish.DoClickThing(); }
        }
    }
}

}
for DoClickThing(); this works
public void ControlFishClick()
{
    screenPos = myCam.WorldToScreenPoint(transform.position);
    Vector3 v3 = Input.mousePosition - screenPos;
    angleOffset = (Mathf.Atan2(transform.right.y, transform.right.x) - Mathf.Atan2(v3.y, v3.x)) * Mathf.Rad2Deg;

}

for DoDragThing() i want this to work
public void ControlFishDrag()
{
    stopMovement = true;
    rigid2D.velocity = new Vector2(0, 0);
    Vector3 v3 = Input.mousePosition - screenPos;
    float angle = Mathf.Atan2(v3.y, v3.x) * Mathf.Rad2Deg;
    transform.eulerAngles = new Vector3(0, 0, angle + angleOffset);
    //print(stopMovement);
}

for DoReleaseClick() i want this
public void ControlFishUp()
{
    stopMovement = false;
    SnapToPosition();
}


texts:
The game is a 2D platformer.

The problem I have is when I press the B button to crouch from standing, I do not know how to implement a function where B can be pressed again to move back to the standing sprite.

the issue is if i use the code presented below it will check every frame for B == Pressed, basically appearing as if the player never crouched at all. Could somebody help please?

if (facingRightSide == true)
        {
            if (currPad.Buttons.B == ButtonState.Pressed)
            {
                m_currState = AnimState.CrouchRight;
                isCrouchedRight = true;
            }
        }

if (isCrouchedRight == true)
        {
            if (currPad.Buttons.B == ButtonState.Pressed)
            {
                m_currState = AnimState.FacingRight;
                isCrouchedRight = false;
            }
        }

Thank you for your time.


texts: Why is my Unity camera chasing player script running slow?

texts:
I have a camera class, that is suppose to chase my player, which works, but its really really slow. It only has this line of code, which makes sense to me, player moves, camera moves.  Any idea of why my game runs slower.

void Update()
{
    transform.position= new Vector3(player.transform.position.x, player.transform.position.y, -10);
}


texts: Unity difference between accessing asset prefab from reference VS from Resources.Load?

texts:
Question point

Does putting prefab asset in inspector's reference and access its content inside in runtime VS. Load the same prefab asset from Resources.Load API, will both cause entire prefab to load and use same memory footprint?

Backgroud

In UNET or it's replacement lib, Mirror, you will have to register list of prefab on NetworkManager to spawn on server and clients.

Under the hood, these prefab references will be sent to registration function ClientScene.RegisterPrefab which in turn access them as far as
prefab.GetComponentsInChildren<NetworkIdentity>();
(I suspect that this will make entire prefab loaded?)

VS

I put those prefab in Resource folder, then use API like Resources.Load / LoadAll to send them to ClientScene.RegisterPrefab (which proved to work too) But many fellow dev warned me about how evil Resources API is and using these will load all data into memory, etc.

Didn't this 2 way ultimately need to access inside of prefab and both need to load entire prefab in? Is there clear advantage for memory footprint for approach?

Some prior research

In official document about resource management, there is some explanation about how resource will load but it still does not clear up difference between these 2 appraoches.

  2.7. Resource lifecycle

  To reduce loading times and manage an application's memory footprint, it's important to understand the
  resource lifecycle of UnityEngine.Objects. Objects are loaded into/unloaded from memory at specific and defined times. An Object is loaded automatically when:

  The Instance ID mapped to that Object is dereferenced
  ...

Foot note/ Some clarification

Why do you need to use Resources.Load?

Take UNET example case here in my question, and notice that it needs to know every prefab that will be use in game, that's including monsters, items, bullet. Sure you can drag and drop these to inspector (like in screenshot) but will become tedious and unorganized very fast on magnitude of 50+ prefabs. So instead I organize them to Resources folder like

Assets/Resources/EnemyPrefab/Stage1/*.*
Assets/Resources/EnemyPrefab/Stage2/*.*
Assets/Resources/ItemPrefab/*.*

To get more organized load pattern. Resources.LoadAll<GameObject>("EnemyPrefab/Stage1") will do as it suggest. And skipping tedious inspector drag and drop work, let alone checking what did I missed to drag and drop.

Can't you just profile it yourself? why asking here?

I could, but if someone already done this work or has knowledge to confirm such behavior, this could be better, thus this question here. And hey, didn't this is how knowledge is shared and this site is for?


texts:
I'm writing a bot for a MOBA game as final project.
Game status is read directly from the screen (that's the requirement).
Now I have come to the AI part. On the first steps it started as some basic IFs, then I tried using a state machine, but there were too many jumps between states. Google lead me into Behavior Trees.
My current tree looks like this

It looks like it would work... And it does mostly... Except for the fleeing part. The fleeing part consists of setting a "safe point" as the current target for the navigator... But because of it being SUCCESSFUL (it has to flee), the selector does not traverse to the Navigation Behavior.
Solutions i'm thinking of

I could make it return FALSE when it's not successful, but then it would check the combat behavior even though it's already fleeing.
I could make a fleeing behavior. Really, that seems like the most logical thing, but it would be some redundant navigation code. I could extract the a branch from the Nav Behavior into a separate object. I'm not sure that's the right way though.

P.S. I'm using apocdev's Tree Sharp as the base for the tree. I don't think it really matters(it acts as it should), but just in case.


texts: How to prevent a cube from falling through a plane in Unity

texts:
I am trying to prevent a player cube from falling through the plane (Battleground) in Unity, but after adding Mesh collider to both the cube and plane, as well as adding a rigidbody, nothing seems to work. The only way I can prevent this from happening is by locking the y axis of the cube, but this is a problem because I am adding in a jumping ability, and the player needs to be able to fall of the map. Is this something I can do within the Unity editor, or do I need to make a script that does that.

To verify, all 3 colliders have "Is Trigger" Enabled, the platform is not designed to be moved, so the X, Y and Z of both the plan's rotation and position are locked, and the material for the colliders are all default. Each of the cubes and the plane's material are custom (Not the collider's material). The X, Y and Z of the cube's rotation are locked. Both cubes have the tag 'player'

The code for player movement is:

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

public class PlayerMove : MonoBehaviour {
    private Rigidbody rb;
    // Use this for initialization
    void Start() {
        rb = GetComponent<Rigidbody>();
    }

    //Update is called once per frame
    void FixedUpdate() {
        float h = Input.GetAxis("Horizontal") * 5;
        float v = Input.GetAxis("Vertical") * 5;

        Vector3 vel = rb.velocity;
        vel.x = h;
        vel.z = v;
        rb.velocity = vel;
    }

}
```


texts: Where can I get a list or data base of light reflectance values for different materials?

texts:
I'm implementing lighting for a WebGL app but I'm not an artist so I don't know how to generate or where to obtain a list of materials with its values (diffuse, specular, ambient and shininess). I've been searching a lot but with no luck.

Is there any list or DB I might have overlooked? Any common repository or something similar?

Thanks in advance.

Note: English is not my main language, let me know if you don't understand something and I'll try to rephrase it.


texts: Staggered Isometric Map: Calculate map coordinates for point on screen

texts:
I know there are already a lot of resources about this, but I haven't found one that matches my coordinate system and I'm having massive trouble adjusting any of those solutions to my needs.
What I learned is that the best way to do this is to use a transformation matrix. Implementing that is no problem, but I don't know in which way I have to transform the coordinate space.

Here's an image that shows my coordinate system:

How do I transform a point on screen to this coordinate system?


texts: Planck.js (rewritten of Box2D.js) - 8 direction box movement

texts:
I have a box in Planck.js. I want to move this box with some keys. How can I do that? My code:

planck.testbed("boxworld", function(testbed) {
  var pl = planck,
    Vec2 = pl.Vec2;
  var world = new pl.World(Vec2(0, 0));

  //Box

  var box = world
    .createDynamicBody(Vec2(0.0, 10.0))
    .createFixture(pl.Box(0.5, 0.5), 20.0);
  box.render = { fill: "#FA8072", stroke: "black" };

  return world;
});


texts: How do I show only the level in monogame?

texts:
How do I remove the blue background shown here
So that only the level is visible without making the sprites/map larger or the window smaller?


texts: Entity System Texture Rendering Performance Java

texts:
I use Artemis and LibGDX.
I have the following two components which manipulate a texture:

ComponentTexture // Stores the texture
ComponentSource // Define a region for the texture, that will only be
                  shown
ComponentSize // The size of the texture
ComponentMirror // Stores wether you want to flup on x and y axe
ComponentOrigin // The origin of the texture
ComponentPosition // The position of the texture
ComponentRotation // Rotation of the texture
ComponentScale // The scale of the texture

Than I have a System that requires the Texture and position component(Thats the minimum to draw a texture) and draw them to screen, before I render I check if it has some possible extra components.

@Override protected void process(Entity entity)
{
    final ComponentTexture  componentTexture    = mComponentTextureMapper.get(entity);
    final ComponentSource   componentSource     = mComponentSourceMapper.getSafe(entity);
    final ComponentSize     componentSize       = mComponentSizeMapper.getSafe(entity);
    final ComponentMirror   componentMirror     = mComponentMirrorMapper.getSafe(entity);
    final ComponentOrigin   componentOrigin     = mComponentOriginMapper.getSafe(entity);
    final ComponentPosition componentPosition   = mComponentPositionMapper.get(entity);
    final ComponentRotation componentRotation   = mComponentRotationMapper.getSafe(entity);
    final ComponentScale    componentScale      = mComponentScaleMapper.getSafe(entity);

    // Texture
    final Texture texture = componentTexture.getTexture();

    // Source
    final Rectangle source;
    if(componentSource == null)
    {
        source = new Rectangle(0, 0, texture.getWidth(), texture.getHeight());
    }
    else
    {
        source = componentSource.getSource();
    }

    // Size
    final Vector2 size;
    if(componentSize == null)
    {
        size = new Vector2(texture.getWidth(), texture.getHeight());
    }
    else
    {
        size = componentSize.getSize();
    }

    // Mirror
    final boolean mirrorX;
    final boolean mirrorY;
    if(componentMirror == null)
    {
        mirrorX = false;
        mirrorY = false;
    }
    else
    {
        mirrorX = componentMirror.isMirrorX();
        mirrorY = componentMirror.isMirrorY();
    }

    // Origin
    final Vector2 origin;
    if(componentOrigin == null)
    {
        origin = new Vector2(0, 0);
    }
    else
    {
        origin = componentOrigin.getOrigin();
    }

    // Position
    final Vector2 position = componentPosition.getPostion();

    // Rotation
    final float rotation;
    if(componentRotation == null)
    {
        rotation = 0;
    }
    else
    {
        rotation = componentRotation.getRotation();
    }

    // Scale
    final Vector2 scale;
    if(componentScale == null)
    {
        scale = new Vector2(1, 1);
    }
    else
    {
        scale = componentScale.getScale();
    }

    mSpriteBatch.draw(texture, position.x - origin.x, position.y - origin.y, origin.x, origin.y, size.x, size.y, scale.x, scale.y, rotation, (int) source.x, (int) source.y, (int) source.width, (int) source.height, mirrorX, mirrorY);
}

I can create 5000 Entities with textures and a small rotation animation.
I'm wondering about the efficiency of this method and how bad of a performance hit I will get from creating a lot of instances in the method.
I plan to optimize this.

Does anyone have a good idea as to how I can get better performance from drawing textures?

How I can avoid the check for every component that the entity has?

Thanks for reading :D


texts:
Texturing in Blender and when I am moving UVs around in the UV/Image Editor I'm finding that I can't move a single UV point without moving all other UVs that are connected to the vertex.

This seems odd to me as the UV unwrap should be completely distinct from the mesh. Is there some odd setting that I don't realise I have turned on?


texts: Using an interpolated game loop (such as Gaffer's final game loop), will the frame be rendered out of sync?

texts:
A highly recommended game loop is one from an article called Fix Your Timestep. It presents a method to update using a semi-fixed time step with interpolated rendering.

The problem with this is that, by interpolating the rendering, you are effectively averaging two states in the game - the current and the previous. If the previous frame is averaged with the current frame, the player will be shown the game slightly delayed.

If the player is stationary in one update, then teleports in the next, the interpolation will show a state where the player is mid-way between a teleport very briefly.

For time-critical games, is my thinking correct that the player may see a different/slightly lagged state on screen (the interpolated state) than what is actually stored in memory?

The only fix I can think of is to interpolate the current state + the next, not yet calculated, state. This gives the correct image on screen instead of a slightly delayed previous image... but then we are stuck in a paradox of calculating the next future update.

Or perhaps the time difference is so minimal that it doesn't matter?

I am referring to the following line, the current state is where we are at this moment in time and not fully displayed:

State state = currentState * alpha + previousState * ( 1.0 - alpha );


texts:
How do I draw a white crosshair in the middle of screen in openGL, it's all well and good knowing how to render objects in 3d space, but I have literally no idea on how to draw something that sticks on the screen no matter what

Would this require a shader? one that does not take into account model view projection matrix? at what point would i draw the cross? after everything to coincide with the painters algorithm? Or do I give it a z value?


texts: Unity Facebook WebGL build... Does this work or not?!?! Getting conflicting answers

texts:
So here is the facebook documentation..

It seems to be saying you can output a Facebook WebGL build from Unity and upload it.
It does not work for me, I get this message when I upload.

"Games must reference one of our supported SDKs via our CDN."

Theres also this thread, with people saying it is not supported.

https://forum.unity.com/threads/facebook-instant-games-support-html5.499198/

Yet the latest version of Unity has a WebGL option when building to Facebook platform.

What is going on?
Does or doesn't this work?


texts:
Situation:
From a first person perspective (camera position) I want to be able to grab an object and have it fixed to the center center of the screen while looking up-down (pitch) and looking left-right (yaw). The yaw works fine. The pitch only works facing the object head on when camera position z > object z. Turning 180 degrees the pitch rotation is opposite. How do I compensate for this. This is what have:

double yawRadians = Math.toRadians(yaw - oldYaw);
double pitchRadians = Math.toRadians(pitch - oldPitch);

//center position of object, minus camera position
double x = grabbedObject.x0 - position.x;
double y = grabbedObject.y0 - position.y;
double z = grabbedObject.z0 - position.z;

double sinX = Math.sin(pitchRadians);
double cosX = Math.cos(pitchRadians);

double sinY = Math.sin(yawRadians);
double cosY = Math.cos(yawRadians);

double sinXY = sinX * y;
double cosXZ = cosX * z;

double newX = cosY * x + sinY * sinXY - sinY * cosXZ;
double newY = cosX * y + sinX * z;
double newZ = sinY * x + cosY * -sinXY + cosY * cosXZ;

grabbedObject.addTranslation(newX - x, newY - y, newZ - z);


texts:
I've always wondered to what extent object orientation is used by videogames, especially huge 3D projects.
I reckon it would be cool that both troll and werewolf inherited its attributes from enemy and overwrote some of them. But maybe classes are too heavy to be practical, I don't know...


texts: How can I send commands to only certain clients?

texts:
I am building a multiplayer game server with Unity. In the game there are players moving around the map. Now, because this map is quite large compared to the number of players, I was thinking to have the server send each clients' position only when they are nearby, and then slow the rate down when they are far away.

At first I was using the convenient SyncVar to do sync everyone's position, until I discovered its shortcomings, that is there is no conditional way to either sync or not a certain value.

I came out with this player synchronization class so far (I removed all optimizations for simplicity):

public class PlayerSyncPositionConditional : NetworkBehaviour {

    Vector3 lastPos;

    void FixedUpdate () {
        TransmitPosition();
    }

    [ClientCallback]
    void TransmitPosition () {
        CmdProvidePositionToServer(transform.position);
    }

    [Command]
    void CmdProvidePositionToServer (Vector3 pos){
        transform.position = pos;
    }

}

Now, what this code does is nothing more than sending its position to the server: when I am looking at the dedicated server instance, each players' position is correct. Also, as expected, each client will not receive any updates.

From my research, I found that instead of SyncVar, I can use Server and ClientRpc to dispatch commands from the server to all clients, so this

 [Server]
 public void MoveTo() {
     RpcMoveTo(transform.position);
 }

 [ClientRPC]
 void RpcMoveTo(Vector3 newPosition) {
     transform.position = newPosition; //this will run in all clients
 }

would move all clients to the transform current position whenever needed.

Now, the problem is that those commands, apparently affect every client, while I only want to affect ones that are near each other.

I know how to have the server issue the MoveTo at any rate I want, setup more than one interval, etc. but I don't know how to have it send only to certain clients at a single time.

I am not asking for the code itself, but I am getting really confused with all these client/server architecture concepts, which class does what, etc. so any heads-up will be greatly appreciated.


texts: Minecraft Forge Look for Entities in a Certain Location

texts: The title mostly explains it. I have a tile entity that is called Energizer. I want this energizer to check to see if there is an EntityItem on top of it and if so, consume it and create energy. The only problem is, I can't figure out how to check for (and receive) an EntityItem in a certain location (on top of it). I considered using a method that searches for nearby entities and then seeing if they were instanceof EntityItem, but I can't even find a method to do that.


texts: Cocos2D-JS Windows App in fullscreen mode (Win32)

texts:
I've been looking for a way to make my Cocos2D-JS app go into fullscreen mode, but there doesn't seem to be much documentation on Cocos2D-JS (or Cocos2D-x-js as some seem to call it.)
This app is to be exported into a Windows Desktop platform (Win32), and so fullscreen mode should work there as well.

I checked the Cocos2D-JS Online API and found cc.screen, which has a method called requestFullScreen, so I tried this:

cc.screen.requestFullScreen(document.documentElement, function() { cc.log('Requesting full screen...'); } );

However, this didn't work on either of the platforms I tested it on (web browser and win32). Since document does not exist when you export the app into win32, I then tried changing it for cc._canvas:

cc.screen.requestFullScreen(cc._canvas, function() { cc.log('Requesting full screen...'); } );

But this did not work either. Is there a way to make the app run in fullscreen mode?

PD: My apologies for any wrong tags I may have included to this question. I added the ones I thought were related to this problem.


texts: Looking for an Open Source Game Engine with Crowd Simulation

texts:
I am looking for a game engine for my school project on computer graphics. There are specific requirements that I do not want to implement by myself, since they are irrelevant for the grade, but relevant for the final result.

So reusing other one's code is a good thing here and I am looking for an engine that supports the following features, or that has plugins/3rd party projects available that can do it for me. I have already been looking for it for 2 days, but maybe some of you might just know the right fit for me.

Requirements:

Open Source / Free [so people can always view back my code without any licensing.]
3D
OO [I'm not so good at C++. Preferred are: Java, C#]
Crowd Simulation [I need walking people in my scene. This could be a 3rd party lib. Probably best with nav meshes.]
Render to Texture [I need panels with moving images on it. Unity3d fails here.]
Multi-project [I cannot adjust the installation folder on my school computer. UDK and CryEngine fail here.]
Networking
Cross Platform (at least for Linux)

Engines that fail my requirements:

CryEngine 3
UDK
Unity3d
OpenSceneGraph: not a real engine. I need more interactive components.
XNA: not cross platform.

Update
I found a nice crowd simulation lib after a long long search: http://gamma.cs.unc.edu/RVO2/ So that is not a big issue anymore

Update 2
Apparently, my mentor wants it to be cross platform. Which is an ouch for XNA.


texts: How to lock aspect ratio when resizing game window in unity?

texts:
I want a scalable game window that when resized stays at 16:9 aspect ratio.  The goal is for the user to be able grab the window on the right or bottom and resize it.  The game should adjust the corresponding side of the view-port to lock the aspect ratio.  I've tried forcing certain values in the update line of a script on the camera, but it did not work. the game is 2d and most of the elements are scripted using the gui functions. I'm having a very hard time finding exactly what I'm looking for as it is, most of what I've found is in an attempt to create black bars and keep the game from stretching, but that doesn't help ongui using matrices.

here are the resources I've tried so far

http://goo.gl/8FuyRC - this one is a script someone wrote that I attached to the main scene camera, I then built it, however that didn't work.

http://goo.gl/qZ5DAl - this is something from the unity website regarding camera aspect ratio. I put a line of code in the update function of my camera object

#pragma strict

function Start () {

}

function Update () {
Camera.main.orthographicSize = 3.596306;
}

as well as

#pragma strict

function Start () {

}

function Update () {
Camera.aspect = 1;
}

none of the above worked.

http ://goo.gl/MbTDcz - was the last thing I tried, and it just made some more black bars...

so far nothing has worked. not sure why. to reiterate, the goal I'm trying to accomplish is that, when the user grabs the edge of a windowed player, and drags it, the corresponding x or y axis will follow in suit to keep the aspect ratio the same.


texts:
This may have been asked already, but I was unable to find it, because I don't really know what I'm looking for. I drew a picture:

I need theta. I've seen various solutions using Vector.Dot, and Math.Atan2, but they don't seem to work...

BTW, I need the output in degrees. On previous tries, I ran my results through MathHelper.ToDegrees(), but got values over 360, which shouldn't be possible.

This is my current code:

    Vector2 mouse = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
    Vector2 delta = mouse - Position;
    angle = Math.Atan2(delta.X, -delta.Y);
    angle = MathHelper.ToDegrees((float)angle);

EDIT: A little more info. I'm making a 2D game, and need the angle to 'rotate' one of  my sprites (simply changing which sprite I'm displaying). The code for how I'm doing this is below.

public static Direction GetDirection(double radians)
        {
            if (radians > GetRadians(Direction.Up).Lower && radians < GetRadians(Direction.Up).Upper)
            {
                return Direction.Up;
            }
            else if (radians > GetRadians(Direction.UpRight).Lower && radians < GetRadians(Direction.UpRight).Upper)
            {
                return Direction.UpRight;
            }
            else if (radians > GetRadians(Direction.Right).Lower && radians < GetRadians(Direction.Right).Upper)
            {
                return Direction.Right;
            }
            else if (radians > GetRadians(Direction.DownRight).Lower && radians < GetRadians(Direction.DownRight).Upper)
            {
                return Direction.DownRight;
            }
            else if (radians > GetRadians(Direction.Down).Lower && radians < GetRadians(Direction.Down).Upper)
            {
                return Direction.Down;
            }
            else if (radians > GetRadians(Direction.DownLeft).Lower && radians < GetRadians(Direction.DownLeft).Upper)
            {
                return Direction.DownLeft;
            }
            else if (radians > GetRadians(Direction.Left).Lower && radians < GetRadians(Direction.Left).Upper)
            {
                return Direction.Left;
            }
            else
            {
                return Direction.UpLeft;
            }
        }
public static Radians GetRadians(Direction direction)
        {
            Radians r = new Radians(0,0);
            switch (direction)
            {
                case Direction.Up:
                    r = new Radians(15 * increment, increment);
                    break;

                case Direction.UpRight:
                    r = new Radians(1 * increment, 3 * increment);
                    break;

                case Direction.Right:
                    r = new Radians(3 * increment, 5 * increment);
                    break;

                case Direction.DownRight:
                    r = new Radians(5 * increment, 7 * increment);
                    break;

                case Direction.Down:
                    r = new Radians(7 * increment, 9 * increment);
                    break;

                case Direction.DownLeft:
                    r = new Radians(9 * increment, 11 * increment);
                    break;

                case Direction.Left:
                    r = new Radians(11 * increment, 13 * increment);
                    break;

                case Direction.UpLeft:
                    r = new Radians(13 * increment, 15 * increment);
                    break;
            }

            return r;
        }


texts: In-app purchases: Restore unlocked items on new device

texts:
I am building a mobile game for Android / iOS with support for in-app purchases. Our game also supports unlock codes (aka promo codes). A user can enter an unlock code in our app to unlock one or more IAP items for free. We want to ensure, that if a user changes his device, we is able to restore all IAP items and unlocked items.

As the promo code feature provided on app stores is either quite limited in functionality or not available at all, we've decided to build our own backend to manage unlock codes. If a user enters an unlock code, we register this in our backend.

So, when a user re-installs the app, we need to talk to two systems to get the full list of purchased/unlocked items:

Talk to app stores to fetch list of purchased items
Talk to our own backend to fetch list of unlocked items

To make sure that the user gets his unlocked items even after an app-reinstall on a different device, we need to have an identifier which is not based on the device but rather on a user account. Unity does not provide access to Apple ID / Google ID, so my question is, how to accomplish this in a good way?

At the moment, the only possible solution I see is this:

Users must register with us (e.g. email and password). We store the list of unlocked items in our own backend. In case of an app reinstall on a new device, the user must login to our backend and unlocked items become available again.

Are there any better solutions to this?


texts: Unity3d Sprite Mask Nonexistent in Build

texts:
I am developing a 2D game which uses sprite masks to limit the player's information to a circle around them. The feature works perfectly in the Unity Editor. It can be disabled and reenabled, have the shape of the mask itself change, and more.

However, whenever I build the project and run the executible the screen is blank. If I disable the sprite masks altogether, the sprites are all visible. I have debugged Unity3d builds before, but that was specifically looking at variables as they changed during the execution of the program.

Does anyone have any specific knowledge related to sprite masks or have any idea why this would occur? I can provide more information if necessary. My current thought is that the sprite mask is masking everything for some reason. It's weird to me though that it would only break in the build.

All help is appreciated.


texts: I want to transform my GUIWindow from the bottom of the screen to the middle whenever the user presses a button. How can I do this?


texts: Efficient update of instance data for instance rendering

texts:
I started implementing instanced rendering in my 3D engine, but I quickly stumbled upon some issues that I'm not sure whats the best practice to work around.

When I setup my scene, I capture the amount of instances for every mesh and I write the transformation matrices first into a dynamic list and finally into an "instance buffer" (UBO) which is sent to the shaders and indexed by gl_InstanceID to fetch the correct transform. This is working perfectly.

So when I apply frustum culling per instance, what I do now is that once I found out that an instance should be culled, I remove this transformation matrix from the dynamic list and therefore I keep the transformation matrices of just the active instances which end up getting drawn from the glDrawElementsInstanced.

Obviously inserting and removing elements from this dynamic list is expensive and I want to get rid of it. So I was thinking that I'll implement a fixed length list this time consisting of per-instance structs to hold instance data something like this:

struct InstanceData {
    float worldMatrix[16];
    bool isOccluded;
    /* and more */
};

However this leads to another problem. In this case, since the draw call will render a fixed amount of instances all the time, regardless if they are visible or not, I'll have to discard the vertices in the shader, and I don't think that this is optimal either.

I've thought of other ways as well, such as sorting the instances based on their occlusion status on every frame, but then I'll have to pay the price for the sorting.

Is there any common practice to deal with instanced data? I fear that I should experiment with all the options and find what suits me best x.x

Thanks in advance


texts:
I can't find anything on how to hint to the driver to disable any antialias.
I'm using a very minimal passthrough setup yet I notice my driver is still doing what looks like MSAA.
I want to disable this, or at least give a strong hint to disable it, so to save performance. As I will be doing deferred rendering with my own SSAA.


texts:
Typically in game development, linear development (waterfall model) is riddled with obstacles that drain the programmer's sanity (game turned out horrid, can't redesign). Enter iterative design. Iterative design allows for prototyping of various possibilities in the play space. Unfortunately, it has a major catch. As soon as a project increases in size, iterations become tediously long killing off the main advantage: rapid results.

How can one shorten design iterations for large scale projects?


texts: Unity C#: Accurate MachineGun Firerate at lower FPS

texts:
I have long accepted that my firerate will be more or less irregular and inaccurate. Now that I'm adding sound things are getting really ugly. My methods for getting the firerate are primitive and I need some help in increasing firerate accuracy.

My Primitive Method #1:

float firerate = 0.1f;
float waitfire;

void Update()
{
    waitfire += Time.deltaTime;

    if (waitfire > firerate) //Fires gun everytime timer exceeds firerate
    {
        waitfire = 0;
        Shoot();
    }
}

The main issue is that the weapons firerate will be significantly slower than it should. 600 rounds per minute come in as 550, while 1300 rounds per minute come in as 1100. The effect is increased dramatically if frames are reduced, because waitFire will always be higher than firerate, more so if frames are low.

Also when using a Debug.Log() in update for counting frames I get A LOT less frames than in-game. If I'm running 200fps, Unity only does 40-60 passes through update. Is this normal?

The result at ca 35fps: (The weapon was intended to cycle at 600rpm)

https://www.youtube.com/watch?v=I6V5ojTyQVQ

My primitive Method #2

float shootTimeCounter; //Counts time since shooting
float autoShotCounter; //Counts number of shots in automatic fire

float firerate = 0.1f

void Update()
{
    shootTimeCounter += Time.deltaTime;

    if (shootTimeCounter > (autoShotCounter * firerate)
    {
        autoShotCounter ++;
        Shoot();
    }
}

Obviously this is not the exact code I am using, I just sketched it in Notepad to properly explain the procedure.

No matter how bad the framerate is, it will shoot 10 shots per second. If frames drop below 10 it will simply fire 2 shots in the same frame. However irregularities are magnified compared to the first method. With Method #2 Time between shots can range between 0.05s and 0.15s. With Method #1 firerate was slower, but at least it stayed above 0.1.

The result also at ca 35fps:

https://www.youtube.com/watch?v=aOapNEaN2I8

Source Engine

I experimented using fps_max in Half-Life 2, comparing the firerate when dropping the framerate. I modified the AR2's mag to hold 100 rounds. It cycles 10 rounds per second. This is the duration it took precisely to empty the whole magazine at following frames per second:

fps_max 300: 10 seconds
fps_max 10: 10 seconds
fps_max 9: 11.3 seconds
fps_max 8: 12.7

There were no irregularities whatsoever in the firerate, only the sound got mangled slightly. So I was sitting there wondering how on earth they managed to pull that off and decided to ask you guys.


texts: Make a object render behind/trough another but make hide it if its behind some other object

texts:
So first of all sorry for this strange title...
I know it may sounds worse and a bit complicated...

But heres my problem :

My player belongs to the "Player" layer.
He stands somewhere on my map, which belongs to the "Map" layer.
When the falls trough the map he isnt visible anymore... but he should ( dont ask why... he just should ).
But the should still be hidden by other objects ( Walls, Trees, other players ).

Player is standing ontop of the ground.

He is hidden by the tree ( works fine ) .

But he also should be visible while in the ground... and than while hes in the ground he also should be hidden by the tree for example.

I already tried to modify the shaders by setting ZTest to Less or Greater. But this caused strange iusses ( Half of the player was rendered and he wasnt hidden by any objects ).
I also tried to modify the render que... but this doesnt worked somehow... it just didnt changed anything...

So what else i could do to achieve this effect ?
I really appreciate any help ! :D


texts:
What is a good architecture for storing game statistics, so that I can retrieve snapshots of it at various moments?

Say I have a game, and the user's statistics initially are:

 {
 hours_played = 0,
 games_played = 0,
 no_of_times_killed = 0,
 }

When the user purchases something for the first time from within the game, the stats are

 {
 hours_played = 10,
 games_played = 2,
 no_of_times_killed = 5,
 }

And when he purchases something for the second time, the stats are

 {
 hours_played = 20,
 games_played = 4,
 no_of_times_killed = 10,
 }

Let me name the events as "purchase1" and "purchase2"

How do I model my statistics, so that at any point in the future, I will be able to retrieve the snapshot of the statistics at the time when "purchase1" was fired.
Similarly for "purchase2" and any other event I will add.

Hope that made sense..


texts: What is the semantic meaning of the position of Unity's transform component?

texts: What is the meaning of the position in a transform component of a game object in Unity? Is it the center of mass?


texts: How to prioritize related game entity components?

texts:
I want to make a game where you have to run over a bunch of zombies with your car. When moving around, the zombies have a few things to take into consideration:

When there's no player around they might just roam about randomly. And even when some other component dictates a specific direction, they should wobble to the left and right randomly (like drunk people). This implies a small, random, deviation in their movement.
They should avoid static obstacles. When they see they are headed towards a wall, they should reorient themselves.
They should avoid the car. They should try to predict where the car will be based on its velocity and try to move out of the way.
When they can, they should try to get near the player.

All these types of decisions they have to do seem like they should be implemented in different components. But how should I manage them? How can I give different components different weights that reflect the importance of each decision (in a given situation)?

I would need some other component that acts as a manager, but do you have any tips on how I should implement it? Or maybe there's a better solution?...


texts:
Say I have a multitude of 2D polygons floating about on a plane. These polygons can have any side count and aren't necessarily regular.

Assuming I know absolutely everything about the polygons (area, collision point, location, velocity, rotation, angular velocity... etc) how to I calculate what happens to two polygons after collision?

I.e. what will their resultant velocities and angular velocities be after collision?

If not an exact solution, what resources could help me learn how to accomplish this?


texts: GameStudio : How to remove object after delay

texts:
When you pick an item in the inventory and drop it to obj_item_ground, this item is send to the ground. That's fine.
I want to add a delay to this item to destroy it, but if I drop 2 items to the ground, only the last is destroy.

Question : How can I create one timer by item dropped ?

Step :

obj_inventory : on Create event

 instance_create(0, 0, obj_item_ground);

obj_item_ground : on Create event

initialTime = 5;
time = 5;
ground = -1;

on Alarm[0] event; if timer is less than 0, object is destroy.

if (time > 0) {
    time -= 1;
    alarm[0] = 30;
} else {
    with (ground) {
        instance_destroy();
    }
}

on Left Pressed event :

if (mouseItem != -1) {
    scr_item_ground_timer();
}

mouseItem is item I drag to the obj_item_ground.

scr_item_ground_timer() :

Here I create the instance of object dropped to the ground and start the alarm[0] timer.

scr_inventory_item_drop(mouseItem);

for (i = 0; i < mouseQuantity; i++) {
 ground = instance_create(obj_player.x + random_range(-30, 4), obj_player.y + random_range(-12, 0), mouseItem);
}
alarm[0] = 30;
mouseItem = -1;

scr_inventory_item_drop is just to clear the array which contains the object dropped.


texts: How should I manage persistent score in Game Center leaderboards?

texts:
Let's say that I'm developing an iOS RPG where the player gains 1 point per monster kill.

The amount of monsters killed is persistent data: it is an endless adventure, and the score keeps on growing. It isn't a "session score" like Fruit Ninja, but rather a "reputation score".

There are Game Center leaderboards for that score. Keep killing monsters, your score goes up, and the leaderboards are updated.

My problem is that, technically, you can log out and log in using a different Game Center account, kill one monster, and the leaderboards will be updated for the new GC account.

Supposing that this score is a big deal, this could be considered as cheating, because if you have a score of 2000, any of your friends who have never played the game can simply log into your iPhone, play the game, and the system will update the score for their accounts, essentially giving them 2000 points in the leaderboards for doing nothing.

I have considered linking one GC account to a specific save game. It won't update your score unless you're using the linked GC account. But what if the player actually needs to change their GC account? Technically they would be forced to start a new game and link their account to that profile.

How should I prevent this kind of cheat? Essentially, I don't want someone to distribute a high schore to multiple GC accounts, given the fact that the game updates the score constantly since it isn't a "session score".

I do realize that it isn't quite a big deal. But I'm curious about how to avoid this.


texts: Playing a sound only once during collisions

texts:
So recently i thought i figured out a solution for it, only to find out it doesnt work when i have more than one of the same object type added to the level.

What i was doing is iterating through my different list of objects and checking if any of them are colliding with the player, if they are i play the sound for that one colliding with the player and then i set the boolean for the sound to true, meaning the sound has been played now.

When their are no collisions going on or if the current object being iterated isnt colliding with the player i set the sound boolean back to false. So as you probably can see, there is a issue when there is more than one of the same objects added because one of them will set the boolean to false and the sound will be played over and over as long as the player is colliding with one of the objects.

So i have run out of solutions to fix this so i am seeking out help.

Thanks anyone who can offer assistance.

EDIT:

Here is an example of how i am doing it now:

private void checkNeutalSwitchers() {

Iterator<Tile> switcherIT = this.neutralSwitcherTiles.iterator();

while (switcherIT.hasNext()) {
    Sprite square_sprite = switcherIT.next();
    float distance = MathUtils.distance(playerBoat.getX(),
            playerBoat.getY(), square_sprite.getX(), square_sprite.getY());
    if (distance < 11) {
        if (square_sprite.collidesWith(player)) {
            if (square_sprite.getUserData().equals("triangle")) {
                playerBoat.detachChild(player);
                player = swithcer.getTriangle();
                playerBoat.attachChild(player);
                if (this.neutralSwitcherBool == false) {
                    this.neutralSwitcherBool = true;
                    this.switchShapesSound.play();
                }

            }
            if (square_sprite.getUserData().equals("square")) {
                playerBoat.detachChild(player);
                player = swithcer.getSquare();
                playerBoat.attachChild(player);
                if (this.neutralSwitcherBool == false) {
                    this.neutralSwitcherBool = true;
                     this.switchShapesSound.play();
                }

            }
            if (square_sprite.getUserData().equals("circle")) {
                playerBoat.detachChild(player);
                player = swithcer.getCircle();
                playerBoat.attachChild(player);
                if (this.neutralSwitcherBool == false) {
                    this.neutralSwitcherBool = true;
                    this.switchShapesSound.play();
                }

            }
            if (square_sprite.getUserData().equals("rectangle")) {
                playerBoat.detachChild(player);
                player = swithcer.getRect();
                playerBoat.attachChild(player);
                if (this.neutralSwitcherBool == false) {
                    this.neutralSwitcherBool = true;
                    this.switchShapesSound.play();
                }

            }
        } else {
            this.neutralSwitcherBool = false;
        }
    }
}

}


texts: JAVA: Unformed Sprite When trying to Read SpriteSheet

texts:
So Im a beginner experimenting with ImageIO. Can someone tell me why im getting this pixelated-incomplete sprite?

Here's the code

public BufferedImage getImage(String location)
{
    try
    {
        File file = new File(location);

        image = ImageIO.read(file);
    }
    catch (IOException e)
    {
        System.err.println("It don't work!!");
        e.printStackTrace();
    }
    return image;
}

And Im using this method to display it

public void paint(Graphics g)
{
    g.drawImage(getImage("Numbers/icon0.png"), 0, 0, 32, 32, null);
    repaint();
}

THANK YOU IN ADVANCE


texts:
I have two CCActions :
CCAction *a;
CCAction *b;

so how to use CCSequence with two CCActions
Thanks


texts: Should a beta version of an engine be used to start a new project?

texts: Is it advisable to use a beta version of unity(2019.3b) to make an actual complete project? What are the disadvantages?


texts:
I'm a beginner android developer currently working on my second app which is a platformer game. I'm trying to read the level map (which I've stored in the assets folder) but I keep getting a FileNotFoundException. This is the code to access it in the game play class:

@Override
public void init() {

    try {
        loadMap("file:///android_asset/map.txt");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

private void loadMap(String filename) throws IOException {

    ArrayList lines = new ArrayList();
    int width = 0;
    int height = 0;

    BufferedReader reader = new BufferedReader(new FileReader(filename));
    while (true) {
        String line = reader.readLine();
        // no more lines to read
        if (line == null) {
            reader.close();
            break;
        }

        if (!line.startsWith("!")) {
            lines.add(line);
            width = Math.max(width, line.length());

        }
    }
    height = lines.size();

    // Rest of the code
}

I have read about using InputStream but my game play class extends State rather than Activity so I'm unable to use it. Can anyone help me out on how I can access the file or how I can work around this problem, it'll be much appreciated.


texts:
How can you scale a point sprite by its distance from the camera?

GLSL fragment shader: gl_PointSize = size / gl_Position.w; seems along the right tracks; for any given scene all sprites seem nicely scaled by distance.  Is this correct?

How do you compute the proper scaling for my vertex attribute size?  I want each sprite to be scaled by the modelview matrix.

I had played with arbitrary values and it seems that size is the radius in pixels at the camera, and is not in modelview scale.

I've also tried:

gl_Position = pMatrix * mvMatrix * vec4(vertex,1.0);
vec4 v2 = pMatrix * mvMatrix * vec4(vertex.x,vertex.y+0.5*size,vertex.z,1.0);
gl_PointSize = length(gl_Position.xyz-v2.xyz) * gl_Position.w;

But this makes the sprites be bigger in the distance, rather than smaller:


texts: How relevant is PHP today for browser games?

texts:
I was the lead developer of 2 moderately successful browser games quite a few years back, and plan on working on a new game soon. At the time, I wrote them in pure PHP (no template engine or anything of the sort).

I'd like to start working on a new game, but have been out of the web development world for a while. Reading around, I hear a lot of good about Rails, Django, Node.js, etc., with which I have no experience (although I know my way around Python, Javascript, and the others quite well).

So my question is the following- if I were to go in my old ways and go with PHP again, would I be making things hard for myself? Would picking something more "trendy" have a real impact on my development?

In addition, does anyone have any pointers relating to specifically developing browser games with these more modern tools?


texts: How can I create a cross-fade between two quads?

texts:
I have two quads, and I would like to have each one of them on the screen for 5 seconds, then fade to the next one. How could this be done?

My code:

package net.makerimages.Unacrawl.stateSys;

import net.makerimages.Unacrawl.graphics.TextureManager;

import static org.lwjgl.opengl.GL11.*;
/**
 * Created by Makerimages on 12.01.14.
 */
public class LogoState extends GameState
{
@Override
public void render() {
    TextureManager.bigLogo.bind();

    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex2f(0, 0);
    glTexCoord2f(1, 0);
    glVertex2f(0 + TextureManager.bigLogo.getTextureWidth(), 0);
    glTexCoord2f(1, 1);
    glVertex2f(0 + TextureManager.bigLogo.getTextureWidth(), 0 + TextureManager.bigLogo.getTextureHeight());
    glTexCoord2f(0, 1);
    glVertex2f(0, 0 + TextureManager.bigLogo.getTextureHeight());
    glEnd();

    TextureManager.makerLogo.bind();

    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex2f(0, 0);
    glTexCoord2f(1, 0);
    glVertex2f(0 + TextureManager.makerLogo.getTextureWidth(), 0);
    glTexCoord2f(1, 1);
    glVertex2f(0 + TextureManager.makerLogo.getTextureWidth(), 0 + TextureManager.makerLogo.getTextureHeight());
    glTexCoord2f(0, 1);
    glVertex2f(0, 0 + TextureManager.makerLogo.getTextureHeight());
    glEnd();
}
}


texts: What's the best practice to use the pbo to upload multi textures?

texts:
I have a basic model to upload textures as shown in the following picture.

I design this for several reasons:

Only the primary thread owns the OpenGL context, so I choose to create buffers, map buffers and unmap buffers in the primary thread.
I have many pictures to load and I don't want them to block the primary thread, so I use the subthread to load images and copy the memory.

Here are my questions:

Is my model correct?
Is my model the best practice?
Should I create a PBO for each picture or create two PBO for all pictures and use them in turn?
Should I use a shared context?

Thank you for helping me out


texts:
Firstly some info - I'm using DirectX 11 , C++ and I'm a fairly good programmer but new to tessellation and not a master graphics programmer.

I'm currently implementing a tessellation system for a terrain model, but i have reached a snag. My current system produces a terrain model from a height map complete with multiple texture coordinates, normals, binormals and tangents for rendering. Now when i was using a simple vertex and pixel shader combination everything worked perfectly but since moving to include a hull and domain shader I'm slightly confused and getting strange results. My terrain is a high detail model but the textured results are very large patches of solid colour.

My current setup passes the model data into the vertex shader then through the hull into the domain and then finally into the pixel shader for use in rendering. My only thought is that in my hull shader i pass the information into the domain shader per patch and this is producing the large areas of solid colour because each patch has identical information. Lighting and normal data are also slightly off but not as visibly as texturing.

Below is a copy of my hull shader that does not work correctly because i think the way that i am passing the data through is incorrect. If anyone can help me out but suggesting an alternative way to get the required data into the pixel shader? or by showing me the correct way to handle the data in the hull shader id be very thankful!

cbuffer TessellationBuffer
{
    float tessellationAmount;
    float3 padding;
};

struct HullInputType
{
    float3 position : POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
    float3 tangent : TANGENT;
    float3 binormal : BINORMAL;
    float2 tex2 : TEXCOORD1;
};

struct ConstantOutputType
{
    float edges[3] : SV_TessFactor;
    float inside : SV_InsideTessFactor;
};

struct HullOutputType
{
    float3 position : POSITION;
    float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float3 binormal : BINORMAL;
    float2 tex2 : TEXCOORD1;
    float4 depthPosition : TEXCOORD2;
};

ConstantOutputType ColorPatchConstantFunction(InputPatch<HullInputType, 3>        inputPatch, uint patchId : SV_PrimitiveID)
{
    ConstantOutputType output;

output.edges[0] = tessellationAmount;
output.edges[1] = tessellationAmount;
output.edges[2] = tessellationAmount;
output.inside = tessellationAmount;

return output;
}

[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("ColorPatchConstantFunction")]

HullOutputType ColorHullShader(InputPatch<HullInputType, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
{
   HullOutputType output;

output.position = patch[pointId].position;
output.tex = patch[pointId].tex;
output.tex2 = patch[pointId].tex2;
output.normal = patch[pointId].normal;
output.tangent = patch[pointId].tangent;
    output.binormal = patch[pointId].binormal;

    return output;
}

Edited to include the domain shader:-

[domain("tri")]

PixelInputType ColorDomainShader(ConstantOutputType input, float3 uvwCoord :    SV_DomainLocation, const OutputPatch<HullOutputType, 3> patch)
{
    float3 vertexPosition;
    PixelInputType output;

// Determine the position of the new vertex.
    vertexPosition = uvwCoord.x * patch[0].position + uvwCoord.y * patch[1].position + uvwCoord.z * patch[2].position;

    output.position = mul(float4(vertexPosition, 1.0f), worldMatrix);
    output.position = mul(output.position, viewMatrix);
    output.position = mul(output.position, projectionMatrix);

    output.depthPosition = output.position;

     output.tex = patch[0].tex;
     output.tex2 = patch[0].tex2;
     output.normal = patch[0].normal;
     output.tangent = patch[0].tangent;
     output.binormal = patch[0].binormal;

    return output;
}


texts: Tips for developing 3D games on newer engines targeting old hardware

texts:
I see a lot of examples and tutorials for 3D engines like Unity3D, UDK, Source etc.  They all seem to be under the assumption that you are making a game for current(ish) hardware.

I would like some tips or tutorials on how to develop a game using UDK, Unity3D or any other modern game engine while targeting what might be considered ancient hardware.

Hardware specs might be as low as

1GHz-1.8GHz single core CPU
8MB-64MB Video chip
512MB-1GB RAM

Thinking along the lines of older laptops or old business class machines that might have, at most, an Intel GMA900 chip or a ATI Radeon 9000 chip onboard.


texts: How can I access the normal map value in Unity?

texts:
I'm simulating laser scanners in Unity with Raycasts, and I've got some "bumpy" items I'd like to scan.
I had tried generating the actual geometry for these objects, but there are tons of these objects and the polygon count exploded.
What I would like to do is something like described here to get the color from a raycast intersection:
Renderer renderer = raycastHit.collider.GetComponent<MeshRenderer>();
Texture2D texture2D = renderer.material.mainTexture as Texture2D;
Vector2 pCoord = raycastHit.textureCoord;
pCoord.x *= texture2D.width;
pCoord.y *= texture2D.height;

Vector2 tiling = renderer.material.mainTextureScale;
Color color = texture2D.GetPixel(Mathf.FloorToInt(pCoord.x * tiling.x) , Mathf.FloorToInt(pCoord.y * tiling.y));

But, instead of getting the color, I'd like to access the normal. I used grayscale bump maps to simulate height differences, but the raycasting doesn't take the normal map into account and I can't figure out how to access normal map values. Ideally there'd be some texture2D.GetNormal() I could use in place of the texture2D.GetPixel() given in the snippet above, but I can't seem to find anything anywhere on getting at the material normals.
I'm using Unity 2019.4, with the Universal Render Pipeline at the moment.


texts:
I have been working on a UI Inventory System for my Unity game and for some reason, none of my buttons work in my game. All the buttons have the ‘interact-able’ box ticked and an EventSystem which is in the scene. In my scene, I have an image, which is holding two buttons, in a canvas. The buttons are supposed initiate a function called UseItem when clicked, but they don't respond to anything. I have tested them using Debug.Log, but I don't get any messages back in the Console. I also don't get any errors or warnings. I am using Unity 2019.4.17f1 LTS.
The pictures below show my UI.
Here's a picture of my game scene:

Here's the complete hierarchy:

These are the EventSystem's configurations:

These are my canvas settings:

And these are use and drop button settings:


texts: Could executing OpenGL shaders sent from a server be dangerous?

texts:
I just came to the realization that since uncompiled shaders are just text, they can easily be sent over a network from a server and then compiled at runtime and executed on clients. I'm not actually planning on doing this (probably...), but I am curious as to whether or not it would result in any potential security vulnerabilities on the clients executing the shaders.

My gut feeling is that it would not, since even if a shader were to gain unauthorized access (eg by reading unallocated data from a video buffer), it would have no way of sending this data back to the attacker. On the other hand, allowing arbitrary code execution seems like an almost certain way to get hacked. My question is how this would be possible in this scenario (assuming that it is).


texts: What concepts are used to procedurally generate video game content using music like in Audiosurf, Beat Hazard & Symphony?

texts:
I'm curious as to how video games like Audiosurf, Beat Hazard and Symphony procedurally generate content using music. What are the common concepts used to accomplish this? And in what way is the music read and interpreted into data that can be used in the game?

Also, I plan on using Java, so if there are any Java-specific information anyone can share, that would be greatly appreciated.


texts: A way around the deprecation of AppInvite in Unity

texts:
I was using FB.Mobile.AppInvite, but according to the Facebook documentation, it is deprecated.

So, how could I send an app invite?


texts: Did retro pixel artists design with CRT's in mind?

texts: There is an often stated claim on discussion boards like Reddit that now retro games of the 8 bit and 16 bit era actually had their art designed with CRT's in mind. I am not talking about video modes or video signals or hardware limitations as a lot of games supported multiple options. I am talking about the final output on the physical device that you observed with your eyes. Did artists really make conscious changes to their art because of this ? (eg. draw the edges of a sprite differently to appear less aliased in a given display)


texts: Unity order issue with TilemapRenderer.Render

texts:
I'm using unity, with 2D Tilemaps (I'm doing something like an RPG)

I want to have a Tile which should be rendered with a random sprite.

When I use a tile like a tree that is bigger than the tile size and RandomTile, the draw order seems to get confused. Even if the sort order on the Tilemap Renderer is set appropriately, some of the tiles are drawing on top of the other tiles with no consistent pattern.

After stepping through with the Frame Debugger, it looks like all tiles with the same sprite are drawn at the same Draw Dynamic event under TilemapRenderer.Render.

I'm using the following script:

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

#if UNITY_EDITOR
using UnityEditor;
#endif

using UnityEngine;

namespace UnityEngine.Tilemaps
{
    [Serializable]
    public class RandomTile : Tile
    {
        [SerializeField]
        public Sprite[] m_Sprites;

        public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData)
        {
            base.GetTileData(location, tileMap, ref tileData);
            if ((m_Sprites != null) && (m_Sprites.Length > 0))
            {
                long hash = location.x;
                hash = (hash + 0xabcd1234) + (hash << 15);
                hash = (hash + 0x0987efab) ^ (hash >> 11);
                hash ^= location.y;
                hash = (hash + 0x46ac12fd) + (hash << 7);
                hash = (hash + 0xbe9730af) ^ (hash << 11);
                Random.InitState((int)hash);
                tileData.sprite = m_Sprites[(int) (m_Sprites.Length * Random.value)];
            }
        }

#if UNITY_EDITOR
        [MenuItem("Assets/Create/Random Tile")]
        public static void CreateRandomTile()
        {
            string path = EditorUtility.SaveFilePanelInProject("Save Random Tile", "New Random Tile", "asset", "Save Random Tile", "Assets");

            if (path == "")
                return;

            AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<RandomTile>(), path);
        }
#endif
    }

#if UNITY_EDITOR
    [CustomEditor(typeof(RandomTile))]
    public class RandomTileEditor : Editor
    {
        private RandomTile tile { get { return (target as RandomTile); } }

        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            int count = EditorGUILayout.DelayedIntField("Number of Sprites", tile.m_Sprites != null ? tile.m_Sprites.Length : 0);
            if (count < 0)
                count = 0;
            if (tile.m_Sprites == null || tile.m_Sprites.Length != count)
            {
                Array.Resize<Sprite>(ref tile.m_Sprites, count);
            }

            if (count == 0)
                return;

            EditorGUILayout.LabelField("Place random sprites.");
            EditorGUILayout.Space();

            for (int i = 0; i < count; i++)
            {
                tile.m_Sprites[i] = (Sprite) EditorGUILayout.ObjectField("Sprite " + (i+1), tile.m_Sprites[i], typeof(Sprite), false, null);
            }
            if (EditorGUI.EndChangeCheck())
                EditorUtility.SetDirty(tile);
        }
    }
#endif
}

Is there any way to fix it?