Kalian bisa menambahkan sebuah file bernama .htaccess di lokasi yang sama dengan file html game Unity yang dibuild oleh Unity, yang isinya adalah kode ini guys:
# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# This configuration has been tested with Unity 2020.1 builds, hosted on Apache/2.4
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
<IfModule mod_mime.c>
# The following lines are required for builds without decompression fallback, compressed with gzip
RemoveType .gz
AddEncoding gzip .gz
AddType application/octet-stream .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz
# The following lines are required for builds without decompression fallback, compressed with Brotli
RemoveType .br
RemoveLanguage .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br
# The following line improves loading performance for uncompressed builds
AddType application/wasm .wasm
# Uncomment the following line to improve loading performance for gzip-compressed builds with decompression fallback
# AddEncoding gzip .unityweb
# Uncomment the following line to improve loading performance for brotli-compressed builds with decompression fallback
# AddEncoding br .unityweb
Di video tutorial ini saya akan berbagi pengetahuan game development Unity tentang cara membuat pesawat terbang yang bisa kamu kendalikan dengan memencet tombol WASD di keyboard.
Berikut ini script Pesawat.cs yang kamu lihat di video di atas:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pesawat : MonoBehaviour
{
public float kecepatan = 10f;
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
rb.velocity = transform.forward * kecepatan;
if(Input.GetKey(KeyCode.W)){
transform.Rotate(.1f,0,0);
}
if(Input.GetKey(KeyCode.S)){
transform.Rotate(-.1f,0,0);
}
if(Input.GetKey(KeyCode.A)){
transform.Rotate(0,0,.6f);
}
if(Input.GetKey(KeyCode.D)){
transform.Rotate(0,0,-.6f);
}
}
}
Di tutorial sebelumnya saya sudah membuat mobil pickup yang bisa dikontrol dengan tombol panah di keyboard untuk menjalankannya. Video itu di sini:
Nah kali ini, tiba saatnya saya menambahkan suara mesin pada mobil ini, yang suaranya nanti bakal terdengar sesuai dengan kecepatan mobil. Kalau mobilnya berjalan kencang, pitchnya dinaikkan, kalau pelan diturunkan, seperti itu lah kurang lebihnya.