Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Is BoxCast/RayCast too expensive to call every frame?
Post Flair (click to view more posts with a particular flair)
Post Body

Hi everyone!

I'm a beginner hobbyist game developer. I'm currently working on a basic 2d platformer with multiple moving enemies. While testing, I noticed that the frame rate drops significantly when I have 10 enemies. Right now I bypass it by deactivating enemies when the player character is outside their "load zone" trigger hitbox, but it's still an issue if there are multiple entities near the player.

My suspicion is that I overused boxcasting/raycasting. I use it for ground and wall checks for the player character and every enemy on every frame. Is raycasting/boxcasting too expensive to be used like this? If so, what's a better alternative? I thought of only checking once every number of frame, but it might affect the responsiveness of the platforming controls. I also thought about using trigger colliders around the units but I'm not sure if this would be faster.

What do you guys think?

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
9,818
Link Karma
6,596
Comment Karma
2,267
Profile updated: 2 days ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago