当前位置:网站首页>Unity Pac Man games, maze implementation
Unity Pac Man games, maze implementation
2022-06-29 22:43:00 【Full stack programmer webmaster】
unity Pac Man games , Maze implementation
Show the effect
This little game is mainly about the movement of the protagonist , Scene: the switch , collision detection .
1 The protagonist moves
int n = 6;
float H = Input.GetAxis("Horizontal") * Time.deltaTime * n;
float V = Input.GetAxis("Vertical") * Time.deltaTime * n;
this.gameObject.transform.Translate(H, V, 0);// Moving functions 2 Scene: the switch
a.transform.localPosition = new Vector3(-100F, 10.3F, -0.87F);
b.transform.localPosition = new Vector3(0, 0, -0);
this.gameObject.transform.localPosition = new Vector3(-22.1F, 10.3F, -0.87F);Let's take a close look at gif picture , I level1 and level2 The above switching is very smooth . Because I'm not replacing scene. For some small games , Try not to use it casually scene Handoff , Otherwise, it will feel like there is a Caton . I've just made the main change of position .
3 collision detection
// Collision function
void OnTriggerEnter(Collider other)
{
// Hit the ball
if (other.name == "ball")
{
Destroy(other.gameObject);
print(ballcount);
ballcount -= 1;
if (ballcount == 0 )
{
if (guanqia == 1)// The next level
{
a.transform.localPosition = new Vector3(-100F, 10.3F, -0.87F);
b.transform.localPosition = new Vector3(0, 0, -0);
this.gameObject.transform.localPosition = new Vector3(-22.1F, 10.3F, -0.87F);
ballcount = 3;
// checkpoint +1
guanqia = guanqia + 1;
}
else// Win.
{
print(" Win. ");
}
}
}
// What I met was the wall
else
{
// Return to the original position
this.gameObject.transform.localPosition = new Vector3(-22.1F, 10.3F, -0.87F);
}
}If you hit a small ball here, you will get a score , Go to the next level . If you hit a wall , It's about to return to its original position .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/2869.html Link to the original text :https://javaforall.cn
边栏推荐
- 5-1 system vulnerability scanning
- Does Australia require that PVC plastic sheets comply with as/nzs 1530.3 with a flame spread index of 0?
- Day9 - user registration and login
- 啃下大骨头——排序(一)
- Introduction, deployment and application of moosefs
- 5-1系统漏洞扫描
- Cloud native enthusiast weekly: cool collection of grafana monitoring panels
- Problem solving metauniverse, multi communication scheme in online games
- 英语没学好到底能不能做coder,别再纠结了先学起来
- Talk about auto in MySQL in detail_ What is the function of increment
猜你喜欢

云原生爱好者周刊:炫酷的 Grafana 监控面板集合

Guangzhou launched a campaign to promote the safety of bottled gas and popularized the knowledge of gas safety

Cloud native enthusiast weekly: cool collection of grafana monitoring panels

《天天数学》连载54:二月二十三日

What are the software testing methods and technical knowledge points?

Unicom warehousing | all Unicom companies that need to sell their products need to enter the general warehouse first

5-1系統漏洞掃描

Three development trends of enterprise application viewed from the third technological revolution

低代码、端到端,一小时构建IoT示例场景,声网发布灵隼物联网云平台

稳!上千微服务接入 Zadig 的最佳姿势(Helm Chart 篇)
随机推荐
Unicom warehousing | all Unicom companies that need to sell their products need to enter the general warehouse first
Grep tool
Three development trends of enterprise application viewed from the third technological revolution
合宙AIR32F103CBT6开发板上手报告
Optional类的高级使用
If I am in Zhuhai, where can I open an account? Is it safe to open an account online?
交友平台小程序制作开发代码分享
Ansible自动化运维
If you master these 28 charts, you will no longer be afraid to be asked about TCP knowledge during the interview
Just like our previous views on the Internet, our understanding of the Internet began to become deeper
26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
PhpSpreadsheet读写Excel文件
Day9 - user registration and login
leetcode 416. Partition equal subset sum partition equal subset sum (medium)
Underlying principles of file operations (file descriptors and buffers)
Basic use of Nacos configuration center
从第三次技术革命看企业应用三大开发趋势
模板函数与特化函数实现高效dynamicCast
Problem solving metauniverse, multi communication scheme in online games
How to use filters in jfinal to monitor Druid for SQL execution?