Textures to Object in Unity / Vuforia - unity3d

I'm trying to do some Augmented Reality in Unity using the Vuforia plugin. I've managed to get everything working (I'm using a 3d model of a car), only the position of the car relative to the marker is wrong when I come to preview it (click the 'Play button at the top and watch through the computer's camera - is 'preview' the right name for this?).
It should be sitting on the the marker in the center, but instead it's floating above the marker and off to the side by quite a bit. The positioning is definitely right in the program itself, so I'm not sure why this isn't reflected in the preview.
Also: at the moment the car is simply an untextured grey object. I realise the textures are included in a subfolder, however I can't drag the entire car's folder (including the Textures subfolder) into the ImageTarget, only the .3ds file itself. Does anyone know how to apply the original textures to the car?
Thanks so much for your help in advance!
Ben

Well, to start answering your question about the drifting away part, you've probably got a Rigidbody attached to your Car? Well, if that's the case, then Go to the Inspector where the Rigidbody is and you'll see constraints.
To avoid it floating off, you might want to check Freeze Positions for whichever direction it needs. Probably Y axis.
Now, I'm not entirely sure if you're using Vector.AddForce to move your objects, but if you are then just check if your car can move if you've put all constraints on.
If you can't then in your code trying using Object.Rigidbody.SetActive(true) when you need it to start moving, and Object.Rigidbody.SetActive(false) when its done.
On the other hand, if you aren't using Vector.AddForce() then remove Rigidbody component if you've used it.
As for the material. If you've got the material in your folder that you've downloaded then just drag and drop it into Assets. Now sometimes your car may be one solid mesh, but some times it may be multiple meshes. So which ever the case. Drag the material from your Assets onto the Hierarchy panel over your car mesh/meshes and it should turn into that color.
Hope it helps. :)

Related

Sprite dislplays all of the frames without acting like an actual sprite

So, i've been trying to make a videogame on unity, and i made my first sprite on piskel. Exported it as PNG but can't seem to make it work on Unity. I imported it as a new sprite and even selected sprite (2D and user UI) on the menu.I selected 2D sprite but it doesn't work. It's just like if I put an image there, and not a sprite.It stays still I even tried using another sprite format More rows
I can't find anyone else with the same problem out there on the internet, so help would be much appreciated. Thank you.
Selecting 2D sprite isn't the full story. You will also need to make the sprite "multiple" instead of "single" and split it up in the editor (now available in the package manager).
That will split it up into frames for you, then you drag and drop a single frame.
https://docs.unity3d.com/Manual/SpriteEditor.html

Prefab in Unity and HoloLens falling below the spatial mapping

I'm working in a Unity application with HoloLens, where I place different prefabs across a room and I use TapToPlace to put it on a surface using SpatialMapping. I works great with some fbx models that I had, but then I received some models that I got in .max format, which I converted to FBX using 3DS Mask, they look good, but the exact setup as the other models, whenever I tap them, they are place halfway below the surface.
I've noticed that the working prefabs puts the cursor right at the bottom when in placing mode, while the "broken" ones put the cursor in the middle. Here is an example of how it looks in Unity:
Working:
Not working:
What is that circle there? it looks like the cursor, because everytime that I tap the object, the cursor is placed exactly there for each prefab, but for the ones in the center, half of the model shows below the surface, somehow it looks like it's related; is there a way to move that to the bottom as the working one looks like? if not, is there something that I need to do in 3DS max when exporting these new models to FBX? both models are using box collider, TwoHandManipulatable and TapToPlace.
Thank you, I appreciate the help.
The issue is on the axisof the model -- the pivot point of the model is not at the bottom of the model.
If at all possible it is recommended that you fix the model in your 3D modelling application, If this is not possible, you can fix it in Unity by adding an extra parent transform, more information please see:
https://answers.unity.com/questions/62675/redefine-axis-of-an-object.html
https://answers.unity.com/questions/357698/can-we-change-the-pivot-points-of-any-gameobject.html

How I fix my character into center of camera with unity 3d

I need a solution for my problem, please.
I make a character in unity 3d base on AR, the problem is when I build the project in my android phone I can found the character or I should to turn a camera for search where is he.
I need to make this object into the center of my camera how can I do this, please ...
The question isn't the clearest, but I suggest attaching the camera to the gameobject you want to see in the editor.
This link is to a unity tutorial.
https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera
Just re-read your question, AR skimed over that at first ... so you dont want to move the camera rather you want to move the object.
To find the middle of the screen in world space is what you asking for.
Camera.current.ViewportToWorldPoint(new Vector3(0.5f,0.5f, 100));
Use your camera to find a point in the world that is in the middle of your view. You have several options, ViewportToWorldPoint for example as shown above. ViewPort calls 0.5,0.5 the middle of the screen, Z is the distance from the Camera origin point.
You could alternativly cast a ray from your camera center screen and find a point on the ground to put your character at ... would need to know more about your wourld set up to help further.
My old answer is how to move a camera ... I will leave it case its useful to you.
[Edit Old Answer]
The other answer will work and is nice and light but has its limitations as your project advances.
I recomend Cinemachine for camera work, in this case a simple Cinemachine virtual camera setting its 'Look At' and optionaly its 'Follow' is what you want.
https://unity3d.com/learn/tutorials/topics/animation/using-cinemachine-getting-started
Cinemachine tutorail above. in short, Cinemachine works with the concept of 'virtual cameras' these are just light easy to use behvaiours that discribe how to 'frame' a shot e.g. what to look at, how to move, etc.
You real camera will get a Cinemachine 'brain' which simply listens to these virtual cameras and sorts out what to do to the real camera to make it happen. Getting to terms with this system will greatly improve your camera work and masivly simplify it.
Things like simply attaching the camera to the player object and similar work but have big limitations that end up biting you in the backside eventually.
Alternativly you can write a script to transform the camera based on your own custom logic the draw back here is the 'ball of code' problem ... that is at first the logic is simple but as you want more and more specific shots framed up it gets to being a spegettie monster quickly.

How can I make a cube hollow on the inside?

In general I wanted to make it in unity3d but I saw that in tutorials, they made it in blender.
This is what I did in unity:
I want to make this high cube hollow on the inside, and make a small door so that I will be able to walk inside the cube. Later on, I want to somehow add stairs but the problem now is how to make it hollow on the inside.
I saw in some places the suggestion to use blender so I tried this tutorial in blender:
Blender
But got stuck there after I checked the Add Mesh Extra Objects and clicked on Save User Settings. I tried then to click on the bottom on Add > Mesh but then I don't have Extra Objects. I have Extras objects like in the tutorial video.
Anyone my main goal is to make the high cube hollow on the inside with a small door on the bottom so I will be able to walk inside.
From what I know Unity3D has no 3DModelling by default (maybe there is something for that in store), so you need to use Blender or some other program (for example Maya). There is https://blender.stackexchange.com/ where you can ask same question (since it is not really unity3d related)
Maybe this will be helpful : https://blender.stackexchange.com/questions/5849/how-do-i-create-a-solid-object-cube
Overall what you could do, but it is not the est way - you can build a everything out of boxes yourself in Unity3D
Try use to boolean modifier. Take a look this tutorial:
Blender 2.6 Tutorial 26 - Boolean Modifier

How to move a tile (sprite) with drag and drop in Unity 2D?

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