Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Damage and deform front or rear of vehicle

Featured Replies

Hello, me again

 

This time I have a question on how to deform a specific part of a vehicle. I am aware of and currently using @NoNameSets method of damage vehicle, as seen here. While this method does damage the vehicle, it is in completely random positions all around the vehicle. I am currently working on a Callout where a vehicle rear ends another, and would like to damage the front and rear of the two vehicles. Does anyone know how I can achieve this?

That code you linked to already has a DamageFront and a DamageRear method.... 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

  • Author
35 minutes ago, PNWParksFan said:

That code you linked to already has a DamageFront and a DamageRear method.... 

 

I created those methods, but they dont work lol

  • Author

Well I figured it out! I am going to post my code here just in case anyone in the future would also like to know:

 

public static void DeformFront(this Vehicle vehicle, float radius, float amount)
{
	// Get dimensions we want to deform
	var dimensions = vehicle.Model.Dimensions;
	var halfWidth = (dimensions.X / 2) * 0.6f;
	var halfLength = dimensions.Y / 2;
	var halfHeight = (dimensions.Z / 2) * 0.7f;

	// Apply random deformities within the ranges of the model
	var num = new Random().Next(15, 45);
	for (var index = 0; index < num; ++index)
	{
		// We use half values here, since this is an OFFSET from center
		var randomInt1 = MathHelper.GetRandomSingle(-halfWidth, halfWidth); // Full width
		var randomInt2 = MathHelper.GetRandomSingle(halfLength * 0.85f, halfLength); // Front end
		var randomInt3 = MathHelper.GetRandomSingle(-halfHeight, 0); // Lower half height
		vehicle.Deform(new Vector3(randomInt1, randomInt2, randomInt3), radius, amount);
	}
}

public static void DeformRear(this Vehicle vehicle, float radius, float amount)
{
	// Get dimensions we want to deform
	var dimensions = vehicle.Model.Dimensions;
	var halfWidth = (dimensions.X / 2) * 0.6f; // Ignore far left and right of dimensions
	var halfLength = dimensions.Y / 2;
	var halfHeight = (dimensions.Z / 2) * 0.7f; // Ignore roof and gound of dimensions

	// Apply random deformities within the ranges of the model
	var num = new Random().Next(15, 45);
	for (var index = 0; index < num; ++index)
	{
		// We use negative values here, since this is an OFFSET from center
		var randomInt1 = MathHelper.GetRandomSingle(-halfWidth, halfWidth); // Full width
		var randomInt2 = MathHelper.GetRandomSingle(-halfLength, -halfLength + (halfLength * 0.07f)); // Rear end
		var randomInt3 = MathHelper.GetRandomSingle(-halfHeight, 0); // Lower half height
		vehicle.Deform(new Vector3(randomInt1, randomInt2, randomInt3), radius, amount);
	}
}

 

Edited by Brexin212

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Similar Content

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.