I'm trying to make a game and I need to render a tileMap that the player can move but also modify its size.
First I created it programmatically, filled it randomly and it worked perfectly fine. As a result I designed a custom tileMap in the scene editor and I used it in code so that the player is able to move it or change its size and there I have a problem.
The tileMap is a 48x48 tileMap but if the intersection between the 24 and 25 column touch the left side of the screen, the whole tileMap (even the part on screen) disappear and if I bring it back on the screen (by selecting the invisible position where it was) and drag it back on the right it reappears.
The only solution that I found is to design the whole tileMap programmatically but this will take quite a long amount of time. Has anyone found how to tackle this issue ?
(changing shouldCullNonVisibleNodes and transparency has no effect)
Related
I am creating a 2D grid based game in Unity. I am using Tile maps for background (one grid and two tile maps).
On the first tile map I have the background (like grass) and on the second one I have things I add, like a hole in the ground. Now I add game objects to the scene (a sprite tree). I have two BoxCollider2D on the tree, first one is just a small one at the bottom of the tree and the other one covers the whole tree but is set as trigger (I have a script that automatically fades out the tree when user is behind it).
The problem is that the user keeps getting stuck at the collider (I think) at the bottom of the tree. It works from some angles. I tried creating a small 2D square too and sometimes I get stuck to that too. What am I missing?
I have added a custom material that has friction set to 0 on both the Player and the tree.
I don't know if it is relevant but the tree is quite big so I had to set its size to 0.5 instead of 1.
remove the interaction between the player and the tree, see in project setting, modify the script to work with a raycast
or just make the tree collider a Trigger..
I have an AR app, where I want to have a plane with text on it, that is always shown when using the AR-Camera.
The Programm only uses the AR-Camera. The Plane doesn´t show up at all so far, even though it does in the preview.
The Plane doesn´t show up anywhere in the AR environment.
I don´t really know what to add since I think the question is simple. If you need further details just let me know.
Little Update: After the start of the app and after the Unity Logo shows up, the screen is black for a few seconds and during that time I can see my Panel on the black background. As soon as the AR-Camera is activated, the Panel is gone.
Here is how to do it in 3 simple steps:
You need to add a Plane object to your Unity's scene
You have to align the Plane in the view of your main Camera's object, to your liking
You have to set the Plane as a child of your Camera's object by simply dragging your Plane entry to Camera entry in the Scene Tree Editor Pane (located in most cases on the left side of your Editor's window)
I have a basic scene with 3 prefabs from the HoloToolkit-Unity package:
HololensCamera + InputManager + CursorWithFeedback
I then add a Canvas (and subsequently a Panel and a Button) to my scene, with the Canvas being in Screen Space - Camera and the HololensCamera being the Render Camera and of course everything was fine, until I noticed that when I run on device, the cube is there as a fixed game object (as one would expect!) but my whole Canvas seems like it is attached to the camera.
Why is this? How do I place a fixed Canvas in my scene?
Read through this
https://docs.unity3d.com/Manual/UICanvas.html
Notice the differences between Overlay/Screenspace/Worldspace
And also try to understand the relation between different camera's and UI elements. If afterwards you still don't understand i'll try to help you.
Defender is an ancient game that presents a virtual world, a horizontal scroller, in a loop. The camera view only portrays a portion of the world at any given time. The player can fly in both directions around this world, continuously.
How could this be achieved with an SKTileMapNode Layout of the world?
My first thought is to have two instances of a SKTileMapNode that illustrates the whole world, and abut them in space where and when required as the player flies around the world.
Here's a map of the Defender world highlighted at the top of the screen:
The minimap in the screen shot you show indicates it is not endlessly scrolling, it’s just really long, with only a small part visible at any time.
Doing this with SKTilemapNode would involve one SKTilemapNode and adding tiles only for the ground, which you could then attach physics bodies to. The background could be a single image or multiple images to create a parallax effect or you could go with a black colour background and stars created with SpriteKit Particles.
An alternate approach would be to use two background images and position them programmatically so as one image scrolls offscreen, it is moved left or right (depending on which way the user is scrolling) to appear adjacent to the other background image, giving the appearance of an endless scrolling background.
I would like to move a tile with drag and drop in Unity 2D. The tile is a sprite. The scene is an 'Unblock me' or 'Blocked in' like gameplay.
Because the tiles in real life correspond to physical objects it seemed be to a good idea to model them with colliders and rigidbody. The border of the table surrunded with invisible colliders. I hoped these will constrain the moves of the tiles realistic, when the player moves them.
Then I implemented a simple (mouse based) drag and drop behavior which is worked perfectly except the moved tile penetrates to other tiles and the border, and sometimes jumps over them. Then I learned if I am overriding physics by explicitly setting transforms position (which I do exactly in my drag and drop implementation), this will happen. OK I accept, I should set only forces, ect. on rigidbody never directly the position.
Now the question:
I am stuck here. I still want to drag and drop like user experience, and some realistic visual result. When in the real life a player moves a tile, it seems it is "glued" to its finger. How can I achieve this (ot at least similar) with just applying forces? Any suggestions or point similar existing sample/blog code?
(I know as a backup plan I can omit all the physics and constrain the tile positions by code, and create some tweens to move the tiles. Is the real solution (what I am asking for) so complicated I should vote on this backup plan?)
Edit
According to comments I've added a video:
There is nothing wrong with the way you are manipulating your dragging. The beauty of developing is being able to do things in your own way. If it works for your game, then don't fret.
Now, i recommend:
Create a new physic material. Assets > Create > Physic Material
Set your new physic material inspector settings both to 0
Attach the physic material to all your wall object colliders. This should allow for your object being dragged to move smoothly against the walls without chopping.
Do a check to see if your mouse is over another collider. If so, then stop the movement in that direction.
Since your movements seem to always be on a single axis, on collision, tell your object to snap to the edge of the wall object. You know the Wall position and scales, also you have the position and scales of the object being dragged. with that you can write a function that will offset it to the correct position when the collision occurs.
Let me know if any of that works out :P