Unity Multiplayer Cube Auto Move? - c#

I have followed the Unity official Multiplayer Guide below and everything works, except for the fact that when I run two instances on the same computer (1 in build run and the other in the play mode) the characters for some reason auto move in a circle.
I have no idea why this is since I have followed the tutorial exactly, unless I missed something :P I am currently on step 9 (identifying local player) and I stopped there cause my players keep moving in circles.
To Clarify, they aren't spinning in place, they are walking in a circle. Just imagine a person following a dotted circle on the floor, same idea.
This issue only happens when i run two instances (build run mode and play mode in unity). if i try only the play mode in unity, everything works fine.
Has anyone experienced this before?
Unity Multiplayer Tutorial: https://unity3d.com/learn/tutorials/topics/multiplayer-networking/network-manager?playlist=29690
I am on version 2017.2.0f3 <-- maybe this is why? should I update to a different patch?
Thank you in advance
Where I spawn the characters
build and run, player just moves in circles automatically
both build run and play mode, they both again moves in circles automatically

I see a first issue in your code:
PlayerController.cs line 36, you wrote
var bullet = (GameObject)Instantiate(BulletPrefab, BulletSpawn.transform.position, BulletSpawn.transform.rotation);
it should be
var bullet = (GameObject)Instantiate(BulletPrefab, BulletSpawn.position, BulletSpawn.rotation);
Since BulletSpawn is already a Transform. Otherwise bullets might not fire in the gun direction.
I don't have any of the player moving without me pressing keybord key.
Here is a screenshot of 2 build run working good:
I also tried Build run + Unity Editor in game mode, I had no problem.
Maybe the problem comes from your keyboard or the input manager of unity ? Since you are using Input.GetAxis, check this https://docs.unity3d.com/Manual/class-InputManager.html

The issue with your character automatically moving is because you have something plugged into your computer that acts as a controller/joytick. Go into settings for controls and set all joystick to the last joystick #. Make sure you set this for all vertical and horizontal movement. That should do the trick.
For example, if you use a 3D mouse like 3D connexion, it could act as a joystick/controller and auto move your character.

Related

How to turn off Pathfinding in navmesh unity?

I use navmesh agent for my Isometric game (diablo like)
how then in all diablo-projects did they make it possible to rest against the wall?
how to off pathfind in nav mesh agent ?
I just want to hit the wall (or game object)
Example
ExampleInPoe
I tried everything, I can't figure out how to do it
You have to use NavmeshObstacles like explained here https://learn.unity.com/tutorial/navigation-basics#5c7f8528edbc2a002053b49c in Step 5.
So your navmesh basically ignores the wall - but the object prevents the player from passing. During runtime you can just remove the object and the path will be walkable.
Update:
In order to force the player to run into the wall (I assume when you say 'rest' against the wall you mean that), you could add a script that recognizes the player when they're close and then takes over their movement to let them smash the wall.
But this isn't a specific question anymore. So I'd rather recommend that you check out the Unity Tutorial section: https://learn.unity.com/search?k=%5B%22tag%3A5d351f087fbf7d006af48180%22%5D And try to get a better understanding of navigation and player movement in general.

Unity Object bounces even before colliding with a boundary collider

Im making a carrom kind of game where Im using physics for striker movement, the problem is my striker object bounces from the edge of the board even before there was a real collision between my striker object collider and the board edge colliders.
Please check this video where I have highlighted my project setup, is I'm doing anything wrong here?
https://drive.google.com/file/d/1xifD--sXHvQWjLbud-Lpt-qG3GAXu-hS/view?usp=sharing
I tried to fix it in many ways but wasn't able to reduce this offset and without resolving this issue I wasn't able to proceed further, because if there are 2 objects very near to each other and if the striker hits only one of those objects accurately still the nearest another object is also considering it as a collision even though there wasn't a real collision!
Is this a known bug? if not how can I remove this offset and can have accurate collisions that are required for carrom kind of games (where multiple objects are near to other)?
I got the mistake that I have done!
In the editor, every time while going to play mode striker object collision detection mode was set to "Continuous Speculative" and at run time I used to change it to "Discrete" or "Continuous" or "Continuous Dynamic" assuming I will be able to change it at run time but that's not the case, even though editor allows us to change collision detection mode at run time, technically it will only consider the mode which was set initially(i.e while starting the play mode), so If I have to see the behavior of "Continuous Dynamic" then I have to stop the play mode and set collision detection mode to "Continuous Dynamic" and run it again!

Unity3D Changing Ball Direction When Hitting a Cube

I'm working on a simple Paddle Game project nowadays. In the begining, everything's looking good. But, when I complete my level design and publish my game, I see gameobjects in my scene are moving so slow. I think, I pass over the Unity3D's physics limit. If I try some Math instead of Unity3D's Colider, I can finish my first project. (I tried to use Separating Axis Theorem, but I can't handle x and y coordinates on Unity3D.)
I need your help. Thanks a lot for your time. (And If I can handle this problem, I will share my project on the internet, for beginner people like me.)
In my project, I achieved this simulation with using BoxColider, but because of Unity3D physics limit, I don't want to use colider in my project.
You can't not detect collision. I'd recommend using Unity's colliders for that, since they're really not bad. The first thing I notice is that in your first simulation, you have 4 box colliders, when instead you should just have one. Use the OnCollisionEnter event (on the spheres) to reflect them off your box.

Discrepancy with screen orientation between Unity3d and iPad, game not affected by device rotation

I'm helping develop a game in Unity3d using C#. We're developing for the iPad and using Unity's
Apple plugin. Our game is a 2-D platform game that features gameplay that uses the rotation of the device (iPad). We're using physics for character movement.
The game is played mostly in Landscape Right. We can change the orientation of the device easy enough using Screen.orientation = ScreenOrientation.LandscapeRight, etc. We want to be able to rotate the device from either LandscapeLeft and LandscapeRight to either Portrait or PortraitUpsideDown, which we can do.
When running our scene within Unity3d, when we rotate from Landscape to Portrait, our character falls because we rotate the world (what she's standing on), while she remains in the same orientation (physics remains the same), causing her to fall. This is the desired behavior we want. However, when we build to Xcode and run the game on the iPad simulator (version 5.1), and we rotate the device so that the world rotates, it merely rotates the device with the game still having the same orientation (landscape). The iPad is in portrait however the game is still in landscape. Are there other variables that we need to set within the device other that ScreenOrientation? How do we have our game state consistent with the device's orientation?
A quick summary: we want our game to default to Landscape. When we rotate to portrait we want the world to rotate with the camera and the player remaining constant. Physics is tied with the character meaning once the world rotates, she falls because she's no longer standing on the ground. Currently when we rotate the iPad, the orientation of the device changes but the game's orientation doesn't change. We want the world to shift on rotation but the character remain constant. It works in Unity3d but doesn't work correctly using the Xcode iPad simulator. How do we do this?
Thank you!
Kenneth
Very confusing question, I must say. Checking the orientation should be simple and straight forward.
First and foremost: Forget XCode simulator! It sucks even if you're building directly on XCode and not using Unity or anything else. Maybe this alone already solves your issue. Get an iPad and test on it.
Also, you'll need scripts in place to handle the physics changing behavior with rotation. I couldn't understand if you got this, but in case you don't this might not be too trivial. Although it seems you got it.
Lastly, the most confusing part is when you talk about ScreenOrientation and Screen.Orientation, and just maybe there's a mistake there. When you use Screen.orientation = ScreenOrientation.LandscapeRight you're forcing the actual screen orientation to change (it is not read-only) and this should be done only for testing purposes. You could even include all code relating to it inside #if UNITY_EDITOR and #endif precompiler 'tags'. For the device, you should only have ScreenOrientation == ScreenOrientation.LandscapeRight, either on if or switch clauses, with the comparison operator, the double equal sign (==).
Can't think of any other thing that could go wrong there.

Unity3d blender fbx file gun is apart

hello i exporting a blender.fbx file into my assets folder in unity and it was working perfectly and i positioned it in front of the camera but when i play it the gun looks like its been taken apart whats going on?!if this helps i separated some parts so i could use it for animation cause it looks like all the animation parts are separate is this a unity thing or a blender thing?
http://www.flickr.com/photos/87198010#N07/7985274177/in/photostream
Two options:
It could be that your animation is incorrect.. remove animation to test..
The position of the child objects, barrel and trigger, may be incorrect in relationship to the parent.. I don't know for a fact, just a few thinks that come to mind.
Let us know when you find out.
When you load a mesh into unity, unity will as a standard add an animation module to it, even if you don't have any animations yet. this may be what is making the gun bug.
If there is an animation component on it, remove said component and try again.
Also it might be that different parts of the gun are at different scales or rotations, before you export from blender click and click 'apply rotation and scale', and then you export.

Categories

Resources