Import 3D asset within a game (Unity 3D)

bagiryu Étiquettes : , , , , , , , , , , , , ,
1-download or model your make and export it. Make sure that it's in an .obj format
2-Create a folder name resources and put your mesh or prefab or gameobject (it's the same behavior) inside the folder
3-Then create a script where you'll use a ressources.Load(); method
4-Add a method to instantiate the mesh
5-Assign the script to an object

>>>Download<<<

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoadMesh : MonoBehaviour
{
    public GameObject Gun; 

    // Start is called before the first frame update
    void Start()
    {
        Gun = Resources.Load("DesertEagleGun") as GameObject; 
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A)) {
            Instantiate(Gun, new Vector3(0,0,0), Quaternion.identity); ;
        }
    }
}

Post you may be interested...

Import 3D asset within a game (Unity 3D) , Distance Between 2 objects (Unity3D) , ...

there are no comments yet ! be the first !

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *