解决 Spawn collision 问题#3185
Merged
Merged
Conversation
timetravler123
commented
Dec 14, 2025
Contributor
在进行多次训练后就会遇到Spawn collision 问题
出生点冲突:随机选择的车辆出生点(spawn_point)已存在其他 Actor(如 NPC 车辆、行人、地图障碍物),直接调用spawn_actor会因碰撞检测失败而报错地面卡模问题部分预设出生点的 z 轴高度与地面贴合过紧,车辆生成时触发碰撞判定,NPC 与主角车辆重叠:NPC 生成逻辑未严格避开主角车辆位置,导致主角车辆出生点被 NPC 占据;
1. 新增 “安全生成车辆” 方法(主角车辆)
重试机制:设计_spawn_vehicle_safely方法,最多重试 20 次生成车辆(可配置spawn_retry_times),每次随机更换出生点,直到找到无碰撞位置,非阻塞生成:使用world.try_spawn_actor替代spawn_actor,该方法在碰撞时返回None而非直接抛异常,允许程序继续重试,高度微调:给出生点 z 轴额外增加 0.2 米,避免车辆因卡地面触发碰撞检测;
donghaiwang
approved these changes
Dec 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.