Unity 3D Several objects not showing on the screen everytime the level is loaded - user-interface

I have a simple 2D game and I have a strange problem whenever a level is loaded several of the objects that include platforms and enemies won't display on screen and neither do the 2D background but all the objects are there, I can see it in the hierarchy and they are functioning as they should like killing the player and such. They just don't show up on the screen. I was finally able to show them while pausing the player during gameplay and set the z position of the camera to -11 and above but every time the level reloads like after the death of player, the same problem happens.
I even tested it on the mobile device but the same problem occurs furthermore I can't even interact with any of the UI buttons on the level, even though I check that all the code for them is appropriate.
Please help.
EDIT:
Okay after reading, your replies, I thought may be this will help. O always get these errors every time I load up this project in unity but they disappear once the game is running.
As you can see the platforms and enemies does appear on the camera frustum but when I start the game they disappear.

Okay, I finally found the problem. After lot of head scratching and testing I found that the objects that weren't appearing on screen has their z-position set to -10 which is the same of that of camera's z-position.
The problem was I was using this code to set the position of objects in the Awake method:
transform.position = camera.main.ViewportToWorldPoint(new Vector3(x, y, 0));
What's actually happening is all the x, y, and z co-ordinates were setting related to the camera's position. So setting the z-position to 10 fixed it for me.
Thanks everyone for helping me.

It's probably because near clipping of your cam is to high; Set it to 0.1 and try it again.

Related

How to stop gamemaker object from leaving tracer

I have just started to use gamemaker and have made my first very basic game, it's just a circle that moves with the arrow keys.
My problem is that when it moves it leaves behind an image of itself in every space that it occupies.
All I have is $motion_set(0, 5);$ as the action.
Any help is much appreciated!
I am not really familiar with Studio 2 but in 1.4 your code causes my sprite to move across the screen without leaving anything behind. Are you sure there is nothing else in your code. It seems to be re-creating a new sprite either at the old location or creating a new object at the old location.
You can also you x += (the ammount of pixels you want to move) This works for x and y.
Thanks, Jonathan Greene

Unity 3D and Mixamo Animation -- Feet Inside of ground

I have a weird problem I can't figure out. I'm new enough to Unity 3D I have a hard time even posing the questions sometimes.
Take a careful look at this picture where I drew the red circles:
The problem is that both in the actual game and in the animation preview, this Mixamo character, using the Mixamo running animation, shows her feet under the ground. Actually, this is a problem with all animations. She does NOT start out under the ground (and in fact starts above ground.) But when the game runs, she falls to the ground (well, she doesn't really fall since she has no ridge body. She appears suddenly at level 0, which you'd think is right on the ground, but in fact it shows her a foot or two under the ground), and the animation then plays with her too low. She doesn't have a ridged body, so that is not the problem.
You can also see my settings for the animation. I've played around with all of them and can't fix it. This happens whether or not I apply root motion or foot IK.
Is there a way to 'lift' the animation up so that it is right on the ground?
I just found an issue in Unity. When i kept the T-Pose Model (Skinned) in a folder and the animation of it in another folder then the Animations turn out to misbehave. Like Legs twitching or parts of body going down. When I brought the T-Pose and other animations together in one folder and updated the reference in Rig of T-Pose then all became normal.
One shitty basic problem is just:
There's an obscure setting actually on "Layers" in Animator, on the "base" layer you have to explicitly turn on "IK Pass".
Only in very unusual situations would you want this "off", just another bizarre mistake by Unity.
Reimporting fixed the problem. I do not know why. It seems that when you play with the animations, they sometimes get corrupted.

Efficiently rendering tiled map using SpriteKit

As an exercise, I decided to write a SimCity (original) clone in Swift for OSX. I started the project using SpriteKit, originally having each tile as an instance of SKSpriteNode and swapping the texture of each node when that tile changed. This caused terrible performance, so I switched the drawing over to regular Cocoa windows, implementing drawRect to draw NSImages at the correct tile position. This solution worked well until I needed to implement animated tiles which refresh very quickly.
From here, I went back to the first approach, this time using a texture atlas to reduce the amount of draws needed, however, swapping textures of nodes that need to be animated was still very slow and had a huge detrimental effect on frame rate.
I'm attempting to display a 44x44 tile map where each tile is 16x16 pixels. I know here must be an efficient (or perhaps more correct way) to do this. This leads to my question:
Is there an efficient way to support 1500+ nodes in SpriteKit and which are animated through changing their textures? More importantly, am I taking the wrong approach by using SpriteKit and SKSpriteNode for each tile in the map (even if I only redraw the dirty ones)? Would another approach (perhaps, OpenGL?) be better?
Any help would be greatly appreciated. I'd be happy to provide code samples, but I'm not sure how relevant/helpful they would be for this question.
Edit
Here are some links to relevant drawing code and images to demonstrate the issue:
Screenshot:
When the player clicks on the small map, the center position of the large map changes. An event is fired from the small map the central engine powering the game which is then forwarded to listeners. The code that gets executed on the large map the change all of the textures can be found here:
https://github.com/chrisbenincasa/Swiftopolis/blob/drawing-performance/Swiftopolis/GameScene.swift#L489
That code uses tileImages which is a wrapper around a Texture Atlas that is generated at runtime.
https://github.com/chrisbenincasa/Swiftopolis/blob/drawing-performance/Swiftopolis/TileImages.swift
Please excuse the messiness of the code -- I made an alternate branch for this investigation and haven't cleaned up a lot of residual code that has been hanging around from pervious iterations.
I don't know if this will "answer" your question, but may help.
SpriteKit will likely be able to handle what you need but you need to look at different optimizations for SpriteKit and more so your game logic.
SpriteKit. Creating a .atlas is by far one of the best things you can do and will help keep your draw calls down. Also as I learned the hard way keep a pointer to your SKTextures as long as you need them and only generate the ones you needs. For instance don't create textureWithImageNamed#"myImage" every time you need a texture for myImage instead keep reusing a texture and store it in a dictionary. Also skView.ignoresSiblingOrder = YES; helps a bunch but you have to manage your own zPosition on all the sprites.
Game logic. Updating every tile every loop is going to be very expensive. You will want to look at a better way to do that. keeping smaller arrays or maybe doing logic (model) updates on a background thread.
I currently have a project you can look into if you want called Old Frank. I have a map that is 75 x 75 with 32px by 32px tiles that may be stacked 2 tall. I have both Mac and iOS target so you could in theory blow up the scene size and see how the performance holds up. Not saying there isn't optimization work to be done (it is a work in progress), but I feel it might help get you pointed in the right direction at least.
Hope that helps.

Renderer running two programs and high vertices/faces

I'm developing a little game in ThreeJs and have stumbled upon a problem I seem not to understand.
Im creating a game instance, after it I'm loading my enemies which are added to an array of enemies. Before I can do it i load my 3D objects with loader.load('assets/data/', callback()) and then create the enemies.
However there are two problems here. As soon as the callback is called my renderer show 2 programs running and the second problem is I'm having huge amount of vertices and faces on only 10 enemy meshes!
Is it that i must go back to blender and set the vertices/faces lower somehow or what am I doing wrong?
Just hint if you need more info!
Regards.

TrackballControls.js issues with MacBook Pro trackpad scroll function

Uncontrollable camera movement in a specific situation. I'm using the mouse scroll wheel to control zoom (pretty standard). Macbook trackpad scroll works with two finger contact and parallel, vertical movement. I haven't experimented with the zoom function when your fingers move apart. Use of the scroll function on the trackpad makes the scene zoom out "infinitely" no matter how far the user's fingers move.
Here's the breakdown:
Using Three.js > TrackballControls.js
Version of Three.js seems irrelevant.
Browser seems to make a slight difference. Problem is exacerbated in Chrome, more stable in Firefox but still there.
Sensitivity doesn't make too much difference. Both examples below use different ZoomSpeed constants.
Examples where the problem can be seen (Macbook required of course):
My current project
TrackballControls.js example page
Thank you for your time!
Added edit 23:00EDT 12/3/13 to specify question:
Sorry I didn't specify. The scroll function of the MacBook trackpad may be accidentally or purposefully used to render the site useless for the user upon each visit. Refresh is the only way to reset the problem. What is the best way to approach this? Detect OS and disable scroll is an option but also a ridiculous one. This is an accessibility problem for any site that uses TrackballControls.js. How are other devs addressing this? Any ideas? That is my question. Thank you for your time!
I was having the same problem. Change the last line of code in the TrackballControl.js mousewheel event handler:
_zoomStart.y += ( 1 / delta ) * 0.05;
to this:
_zoomStart.y += delta * 0.01;
If your trackpad is anything like mine, it fires the mousewheel event more times but in smaller increments. Since the mousewheel delta was being inverted, the smaller increments were becoming larger increments, and since there were more of them, the zoom was being adjusted exponentially more. I'm not sure why it's inverted like that in the original code.

Resources