当前位置:网站首页>UE4 random generation of items
UE4 random generation of items
2022-07-24 06:11:00 【It's really all right, duck】
This is just a brief explanation of the probability of item generation , You can expand on this basis according to your own needs
Create two structural blueprints

Respectively represent the position of the object and the object model to be generated
stay ST_Location Create a Vector Variable

stay ST_Item Create two variables inside

They are the probability of the current item and the probability of this item Actor quote
Then according to the blueprint of these two structures , Create two data tables


stay DT_Location Add five lines to it
Then we're going to set positions for these five lines
Drag five cubes out of the map , Set the positions of the five cubes to DT_Location


The location can be copied and pasted directly


Then pull out five cubes
Create four actor The blueprint ( add to StaticMesh, And then put Mesh Change it to the model you want ), Model casual , Not the same
Here is a blueprint for demonstration , But if you have to generate a lot of items, it will be troublesome , The solution is to create a parent blueprint through the item ID To modify the blueprint StaticMesh

Then set it up DT_Item

BluePrint Set them to the four item blueprints just created , The probabilities are 10,20,30,40
And then create a GameMod

Change the game mode in the world outline to MyGameMod

We are GameMod It realizes the operation of generating items
Create a function , Name it GenerationItem, Traverse the previously created location data table

Every time you get a location, you randomly generate an item , Create another function named RandomItem, This function is used to randomly generate a class reference of an item
Create a local variable in this function Arr, The type is Actor Reference array

The principle is Arr The number of corresponding probabilities of items added to the array , And then we'll make a random item

Then back GenerationItem This function is called in the function to generate items

In the event icon begin play Call back GenerationItem that will do

Run to generate items as follows

If there is anything wrong, please correct it in the comment area
If you have any questions, you can ask me in the comment area
边栏推荐
- Foundation of JUC concurrent programming (4) -- thread group and thread priority
- Oserror: [winerror 127] the specified program cannot be found. Error loading “caffe2_detectron_ops.dll“ or one of its dependencies
- HoloLens 2 中文开发文档 MRTK v2
- The problem that the user name and password are automatically filled in when Google / Firefox manages the background new account
- In GCC__ attribute__ ((constructor) and__ attribute__ ((destructor)).
- Day2 websocket+ sort
- 餐饮数据统计分析---泰迪云课程大作业
- Write the list to txt and directly remove the comma in the middle
- CRC-16 MODBUS code
- Foundation of JUC concurrent programming (7) -- multithread lock
猜你喜欢

day1-jvm+leetcode
![[activiti] gateway](/img/8c/c89ec6c4c5871a32218ddadfd8beba.png)
[activiti] gateway

JDBC进阶—— 师承尚硅谷(DAO)

JUC concurrent programming foundation (9) -- thread pool

Conversion of world coordinate system, camera coordinate system and image coordinate system

JVM system learning

MySql下载,及安装环境设置

Unicast, multicast, broadcast, tool development, introduction to QT UDP communication protocol development and source code of development tools

UE4:浅谈什么是GamePlay框架

Thymeleaf quick start learning
随机推荐
Opencv reads avi video and reports an error: number < Max_ number in function ‘icvExtractPattern
精确计算时间延迟VxWorks 时间戳 详解
Dameng database_ Common initialization parameters
Detailed explanation of KMP code distribution
C language linked list (create, traverse, release, find, delete, insert a node, sort, reverse order)
unity最新版本的Text(TMP)UI文本怎么显示中文
Dameng database_ Logical backup
【数据库系统原理】第五章 代数和逻辑查询语言:包、扩展操作符、关系逻辑、关系代数与Datalog
Foundation of JUC concurrent programming (1) -- related basic concepts
[deep learning] handwritten neural network model preservation
JUC并发编程基础(1)--相关基础概念
JVM系统学习
In GCC__ attribute__ ((constructor) and__ attribute__ ((destructor)).
Openpose2d转换3d姿态识别
Qt char型转QString型 16进制与char型 转 16进制整型
KMP代码分布详解
unity2D游戏之让人物动起来-上
Jupyter notebook select CONDA environment
[principles of database system] Chapter 4 advanced database model: Unified Modeling Language UML, object definition language ODL
String methods and instances