#StackBounty: #unity #c# #collision-detection How to efficiently keep the player from moving outside the gameobject he is colliding with?

Bounty: 50

I am developing a game with Unity 2017.
The game mechanics are as follow:

  • Classic top-down RPG;
  • Movements are: UP, DOWN, LEFT and RIGHT;
  • Player evolves in a 16*16 map;
  • He can dig in the direction he wants to make his way through the map one tile at a time;

At first I was using a very classical approach using tilemaps, RigidBody2D and BoxCollider2D on tiles and the player GameObjects.

Collision detections went fine and my tilemap looked pretty much like that (red being the walls and white the empty spaces):

Classic tilemap

The problem with this approach is that I have to keep in memory the state of 256 tiles in a List<Vector2f> and to create the 256 expected GameObjects representing either my walls (which a totally black), or my floor (the empty space).

Creating a black GameObject with its own BoxCollider2D for each of the tile seems a little bit overkill. And this brings me to the second iteration of my game: to keep in memory only the tiles the player digged.

Expected tilemap

What I would like to achieve efficiently, is to let the player evolve as long as he is colliding with an underlying tile, but stop moving as soon as he doesn’t.

This is ok:

This is ok

This isn’t, and player should be placed to previous state.

This isn't

I could take advantage of OnTriggerEnter2d and handle custom collision and response, but I have the feeling that something more simple and more optimized may exists somehwhere in the wild!

Thanks to any help provided!


Get this bounty!!!

#StackBounty: #unity #algorithm How to "place" object in a 3d world without overlapping them ?

Bounty: 150

I would like to place object in a 3d world “like minecraft player can do”.

What I’m trying to do is to allow the user to place objects, without overlapping them (like in minecraft you can do).

So if the player try to place an object partially over another, my game automatically “move and place” the object in the allowed position.

What can be the right approach ?


Get this bounty!!!

#StackBounty: #unity #virtualbox #3d 3D Acceleration Not working with Virtualbox Tools 5.2.6

Bounty: 100

According to other posts I do the following…

/usr/lib/nux/unity_support_test -p  
OpenGL vendor string:   VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 5.0, 256 bits)
OpenGL version string:  3.0 Mesa 17.2.4

Not software rendered:    no
Not blacklisted:          yes
GLX fbconfig:             yes
GLX texture from pixmap:  yes
GL npot or rect textures: yes
GL vertex program:        yes
GL fragment program:      yes
GL vertex buffer object:  yes
GL framebuffer object:    yes
GL version is 1.4+:       yes

Unity 3D supported:       no

So I try rerunning the autorun and add vboxvideo to /etc/modules and then shutdown and restart with 3D acceleration checked. When I do this, however, after the initial screen with ubuntu and the little dots it just gets stuck on a black page.

How do I get Ubuntu to boot with 3D acceleration installed?


Get this bounty!!!

#StackBounty: #unity #python #indicator #c #dbus How do I write a Unity system indicator in Python?

Bounty: 50

Background:

C Original Code: (working fine)

  • I already get one working in C language, see my other question:

    How to develop a System Indicator for Unity?

    However, indicator-sysmonitor is already developed in Python as many other application indicators. I don’t like the idea that developers obliged to port their projects to C or write a Python-C proxy if they want to show the indicator in greeter/lock/ubiquity screens. Instead, making indicator-sysmonitor creates a system indicator directly from python would be the best solution (no workarounds, and it will be a generic solution for all python projects that currently using appindicator).

Python Code: (My failed trial to port c code to python)

  • I’m struggling to port it into Python. Here is my current code which doesn’t work. It does create DBus object for both Menu & Actions. It is listed in the XFCE indicators plugin. But not showed on the panel.

    /usr/lib/indicator-test/indicator-test-service

    #!/usr/bin/python2
    
    import os
    import sys
    
    import gi
    from gi.repository import Gio, GLib
    
    APPLICATION_ID = 'local.sneetsher.indicator.test'
    DBUS_MENU_PATH = '/local/sneetsher/indicator/test/desktop'
    DBUS_ACTION_PATH = '/local/sneetsher/indicator/test'
    
    def callback():
        print ok
    
    def quit_callback(notification, loop):
        global connection
        global exported_action_group_id
        global exported_menu_model_id
    
        connection.unexport_action_group (exported_action_group_id)
        connection.unexport_menu_model (exported_menu_model_id)
    
        loop.quit()
    
    def cancel (notification, action, data):
        if action == "cancel":
            print "Cancel"
        else:
            print "That should not have happened (cancel)!"
    
    def bus_acquired(bus, name):
        # menu
        submenu = Gio.Menu()
        submenu.append("Show", "show")
        item = Gio.MenuItem.new(None, "_header")
        item.set_attribute([("x-canonical-type","s","com.canonical.indicator.root")])
        item.set_submenu(submenu)
        menu = Gio.Menu()
        menu.append_item (item)
    
        actions = Gio.SimpleActionGroup.new()
        action1 = Gio.SimpleAction.new("_header", None)
        actions.insert(action1)
        action2 = Gio.SimpleAction.new('show', None)
        actions.insert(action2)
        action2.connect("activate",callback)
    
        global connection
        connection = bus
    
        global exported_action_group_id
        exported_action_group_id = connection.export_action_group(DBUS_ACTION_PATH, actions)
    
        global exported_menu_model_id
        exported_menu_model_id = connection.export_menu_model(DBUS_MENU_PATH, menu)
    
    def setup ():
        #bus connection
        Gio.bus_own_name(Gio.BusType.SESSION, APPLICATION_ID, 0, bus_acquired, None, None)
    
    if __name__ == '__main__':
    
        connection = None
        exported_menu_model_id = 0
        exported_action_group_id = 0
        password = ""
    
        loop = GLib.MainLoop()
        setup ()
    
        loop.run()
    

    local.sneetsher.indicator.test

    [Indicator Service]
    Name=indicator-test
    ObjectPath=/local/sneetsher/indicator/test
    
    [desktop]
    ObjectPath=/local/sneetsher/indicator/test/desktop
    
    [desktop_greeter]
    ObjectPath=/local/sneetsher/indicator/test/desktop
    
    [desktop_lockscreen]
    ObjectPath=/local/sneetsher/indicator/test/desktop
    

    local.sneetsher.indicator.test.service

    [D-BUS Service]
    Name=local.sneetsher.indicator.test
    Exec=/usr/lib/indicator-test/indicator-test-service
    

    90_unity-greeter.gschema.override

    [com.canonical.unity-greeter]
    indicators=['ug-accessibility', 'com.canonical.indicator.keyboard', 'com.canonical.indicator.session', 'com.canonical.indicator.datetime', 'com.canonical.indicator.power', 'com.canonical.indicator.sound', 'local.sneetsher.indicator.test', 'application']
    

Question:

I expect the reason why, I didn’t create the menu structure or its meta (pseudo items like _header) as they are in the original C code.

Could anyone make a working port of this system indicator code in C to Python?


Get this bounty!!!

#StackBounty: #unity #algorithm #camera How to calculate Camera "correct" position and distance to Frame all my Scene?

Bounty: 100

Consider I have N dynamic points on my Scene, I would like to “frame” all them, with my Camera.
enter image description here

How can i calculate (at runtime) Vector3 Position to correctly frame all my scene ?

This is my idea:

  1. Calculate Avarage for all my points

  2. Move my Camera “up” to correctly “frame” all my points (i don’t know how)

  3. Use Unity LookAt(myAvaragePoint)

Thanks


Get this bounty!!!

#StackBounty: #unity #shaders #shaderlab How can I make natural rain drops on screen?

Bounty: 50

I’m trying to make rain effect drop with metaballs and trail on screen.I find a clue in shadertoy but I didn’t understand how implemented:

https://www.shadertoy.com/view/ltffzl

unfortunately it have many math calculations and i can’t use it in unity because it produces a lag.obviously I should use textures but how can I have trail effect?!

enter image description here

my idea is using a texture and trail renderer for droping but how can I have metaballs effect?
enter image description here


Update

I could Implement Metaballs by This Article

https://github.com/smkplus/RainFX/tree/master

but I haven’t Idea about trail


Get this bounty!!!

#StackBounty: #unity Instantiating prefabs by dragging in scene not working

Bounty: 100

So I have this problem where I try to instantiate prefabs as in this video for example. I can take instantiate one prefab to the scene, but if I try to instantiate a second one to the scene (whether it’s with the same prefab or a different one), instead of creating an instance of the second prefab, it brings the first instance I had created to my mouse and I’m in position to move it by dragging it around.

The only work around I have for this so far is to drop into the hierarchy instead of the scene (which works fine), but I have to carefully avoid the scene while dragging and dropping, otherwise the above-described issue happens instantly.

Am I doing something wrong, or is this a bug of some kind?


Get this bounty!!!

#StackBounty: #unity #shaders Using a dissolve shader as well as the Standard shader

Bounty: 50

I’m applying a “burning” dissolve shader to an object which uses the Standard shader already. Because I need the Standard shader for better lighting, etc, I looked into how to use them “both” or how to extend the standard shader.

According to the Unity docs I can define which lighting mode I want to use in the pragma so I used Standard. That must not work the way I thought, because I see none of the lighting I do when using the standard shader directly.

I’m using the burning dissolve shader from Harry Alisavakis

Shader "Custom/BurnDissolve" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _SliceGuide("Slice Guide (RGB)", 2D) = "white" {}
        _SliceAmount("Slice Amount", Range(0.0, 1.0)) = 0

        _BurnSize("Burn Size", Range(0.0, 1.0)) = 0.15
        _BurnRamp("Burn Ramp (RGB)", 2D) = "white" {}
        _BurnColor("Burn Color", Color) = (1,1,1,1)

        _EmissionAmount("Emission amount", float) = 2.0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
        Cull Off
        CGPROGRAM
        #pragma surface surf Standard

        fixed4 _Color;
        sampler2D _MainTex;
        sampler2D _SliceGuide;
        sampler2D _BumpMap;
        sampler2D _BurnRamp;
        fixed4 _BurnColor;
        float _BurnSize;
        float _SliceAmount;
        float _EmissionAmount;

        struct Input {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutputStandard o) {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            half test = tex2D(_SliceGuide, IN.uv_MainTex).rgb - _SliceAmount;
            clip(test);

            if (test < _BurnSize && _SliceAmount > 0) {
                o.Emission = tex2D(_BurnRamp, float2(test * (1 / _BurnSize), 0)) * _BurnColor * _EmissionAmount;
            }

            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Standard"
}

I also tried adding this as another subshader to a copy of the Standard shader source, but I wasn’t able to get it working there. If I put it before the others, it works as if it was alone, if I put it after, the standard shader works like if it was alone.

I’m still new to shaders so I’m sure I’m misunderstanding this. How can I get the dissolve shader to apply as well the standard shader, without hopefully having to manually rewrite stuff.


Get this bounty!!!