C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# How to create an object in a cube in Unity3D?

By : deepa
Date : November 28 2020, 08:01 AM
To fix this issue If you know the 8 vertices of your cube, it's easy to randomize an object inside of this cube. Consider the random object to have an x, y and z value in the position of the Transform. Both UnityScript and C# provide a nice Random class which can easily give you a random number between two values. Use this class three times:
Create a random number between the max x value and the min x value of all 8 vertices. Create a random number between the max y value and the min y value of all 8 vertices. Create a random number between the max z value and the min z value of all 8 vertices.
code :

Share :

## Render 3d object (cube) with image target from unity3d (vuforia) to ios?

By : Rupali
Date : March 29 2020, 07:55 AM
this one helps. Here I am new to vuforia qualcomm projects for AR. I used unity3d to generate project (image Target framwork). After built and run app from unity3d the ios app able to render camera on screen but after moving camera on target image it's not render the 3d object(cube) , Have you enabled the dataset in the ARCamera as well?

## Unity3D, cube object not colliding

By : user1416606
Date : March 29 2020, 07:55 AM
this one helps. When you set a collider to act as a trigger, it no longer works as something that you 'collide' physically with. Instead, it allows another collider to enter its space and then it sends off a different type of message back to unity.
If you want it to be that they bump into the object and it physically moves, don't make it a trigger. If you want them to be able to sort of 'enter its space', make it a trigger.

## How to move cube in trajectory in Unity3D

By : ParameshPolam
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The major problem is that using cam.ScreenToWorldPoint(Input.mousePosition); with a perspective camera always returns the position of the camera (this is a very common mistake), so instead of working with the mouse position vs the cube, you're working with the camera vs the cube.
You need to use another method to use the position of the mouse considering where the cube is compared to the camera.
code :
``````cubePosition = Player.transform.position;
if ((Input.GetKey(KeyCode.Mouse0) && cubeisClicked) && ((rb.velocity.x == 0f && rb.velocity.y == 0f)))
{
cubeisClicked2 = false;

Plane cubePlane = new Plane(cam.transform.position - cubePosition, cubePosition);

// reusing camRay

// Determine if we are even hitting the plane
float enter = 0.0f;

if (cubePlane.Raycast(camRay, out enter))
{
cubeisClicked2 = true;
fingerPosition  = camRay.GetPoint(enter);
``````
``````        cubeFingerDiff = cubePosition - fingerPosition;
ShotForce = new Vector3(cubeFingerDiff.x * shootingPowerX , cubeFingerDiff.y * shootingPowerY, cubeFingerDiff.z * shootingPowerX );
if (cubeFingerDiff.magnitude>0.4f)
{
trajectoryDots.SetActive(true);

}
else
{
trajectoryDots.SetActive(false);
}

for (int dotNumber = 0; dotNumber < NumberOfDots; dotNumber++)
{
x1 = cubePosition.x + ShotForce.x * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift);
y1 = cubePosition.y + ShotForce.y * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift) + (Physics.gravity.y / 2f * Time.fixedDeltaTime * Time.fixedDeltaTime * (DotSeparation * dotNumber + dotShift) * (DotSeparation * dotNumber + dotShift));
z1 = cubePosition.z + ShotForce.z * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift);
Dots[dotNumber].transform.position = new Vector3(x1, y1, z1);
``````
``````        }
}
}

if (Input.GetKeyUp(KeyCode.Mouse0) && cubeisClicked2)
{
cubeisClicked2 = false;
trajectoryDots.SetActive(false);

rb.velocity = new Vector3 (ShotForce.x, ShotForce.y, ShotForce.z);;

}
``````
``````cubePosition = Player.transform.position;
if ((Input.GetKey(KeyCode.Mouse0) && cubeisClicked) && ((rb.velocity.x == 0f && rb.velocity.y == 0f)))
{
cubeisClicked2 = false;
Plane cubePlane = new Plane(cam.transform.position - cubePosition, cubePosition);

// reusing camRay

// Determine if we are even hitting the plane
float enter = 0.0f;
if (cubePlane.Raycast(camRay, out enter))
{
cubeisClicked2 = true;
fingerPosition  = camRay.GetPoint(enter);

cubeFingerDiff = cubePosition - fingerPosition;
ShotForce = new Vector3(cubeFingerDiff.x * shootingPowerX , cubeFingerDiff.y * shootingPowerY, cubeFingerDiff.z * shootingPowerX );
if (cubeFingerDiff.magnitude>0.4f)
{
trajectoryDots.SetActive(true);

}
else
{
trajectoryDots.SetActive(false);
}

for (int dotNumber = 0; dotNumber < NumberOfDots; dotNumber++)
{
x1 = cubePosition.x + ShotForce.x * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift);
y1 = cubePosition.y + ShotForce.y * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift) + (Physics.gravity.y / 2f * Time.fixedDeltaTime * Time.fixedDeltaTime * (DotSeparation * dotNumber + dotShift) * (DotSeparation * dotNumber + dotShift));
z1 = cubePosition.z + ShotForce.z * Time.fixedDeltaTime * (DotSeparation * dotNumber * dotShift);
Dots[dotNumber].transform.position = new Vector3(x1, y1, z1);
}
}
}

if (Input.GetKeyUp(KeyCode.Mouse0) && cubeisClicked2)
{
cubeisClicked2 = false;
trajectoryDots.SetActive(false);

rb.velocity = new Vector3 (ShotForce.x, ShotForce.y, ShotForce.z);;

}
``````

## How to move cube in unity3d & C#?

By : user3298085
Date : March 29 2020, 07:55 AM
it fixes the issue You can't call GameObject.Find() directly there, you should be getting an error in the console.
code :
``````public class TRAIN : MonoBehaviour
{
GameObject cube;

void Start()
{
cube = GameObject.Find("cube1");
}
``````