# PRIM_MATERIAL

*LSL constant*

```lsl
integer PRIM_MATERIAL = 2;
```

Constant groups: [PrimParam](/constants/groups/PrimParam/), [PrimParamGet](/constants/groups/PrimParamGet/)

Sets the prim material. Material does not affect mass, but does affect friction, bounce (elasticity), and collision sound. On a wood incline of 33 degrees, the example script below gave the following results:

**Table detailing maximum velocity and distance traveled down the incline.**

| Type | Velocity (m/s) | Distance (m) |
| --- | --- | --- |
| [Stone](/constants/PRIM_MATERIAL_STONE/) | 0.453181 | 0.361655 |
| [Metal](/constants/PRIM_MATERIAL_METAL/) | 5.475444 | 10.211180 |
| [Glass](/constants/PRIM_MATERIAL_GLASS/) | 6.483150 | 11.678304 |
| [Wood](/constants/PRIM_MATERIAL_WOOD/) | 2.154549 | 9.433724 |
| [Flesh](/constants/PRIM_MATERIAL_FLESH/) | 0.351543 | 0.188043 |
| [Plastic](/constants/PRIM_MATERIAL_PLASTIC/) | 4.502428 | 9.590952 |
| [Rubber](/constants/PRIM_MATERIAL_RUBBER/) | 0.374964 | 0.187106 | Prim parameter \[PRIM_MATERIAL, integer PRIM_MATERIAL\_\*\] to get or set the prim's material.

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-56, 62-77}
// © 2008 by Karzita Zabaleta
// Author of Scripting Your World, Wiley, October 2008.

list gMaterialTypes = [
  "STONE",
  "METAL",
  "GLASS",
  "WOOD",
  "FLESH",
  "PLASTIC",
  "RUBBER"
];

vector   gHomePosition;
rotation gHomeRotation;
integer  gWaitCount = 0;
float    gMaxVelMag;
integer  gPrimMaterial;

moveTo(vector origin, vector destination) {
    float dist = llVecDist(origin, destination);
    integer passes = llCeil( llLog(dist/10.0) / llLog(2.0) );
    integer i;
    list params = [PRIM_POSITION, destination];
    for (i=0; i<passes; i++) {
        params = (params=[]) + params + params;
    }
    // actually move the prim, now
    llSetPrimitiveParams(params);
}

returnHome()
{
    llSetStatus(STATUS_PHYSICS, FALSE);
    moveTo(llGetPos(),gHomePosition);
    llSetTimerEvent(0);
    llSetRot(gHomeRotation);
}

calculate_velocity()
{
    float velMag = llVecMag(llGetVel());
    if (velMag > gMaxVelMag) {
        gMaxVelMag = velMag;
    }
}

default
{
    state_entry() {
        gHomePosition = llGetPos();
        gHomeRotation = llGetRot();
    }
    on_rez(integer _n) {
        llResetScript();
    }
    touch_start(integer n) {
        gMaxVelMag = 0;
        llSetPrimitiveParams([PRIM_MATERIAL, gPrimMaterial]);
        llSetStatus(STATUS_PHYSICS,TRUE);
        llSetTimerEvent(0.1);
        llResetTime();
        gWaitCount=0;
        gPrimMaterial++;
        if (gPrimMaterial == 7 ) gPrimMaterial = 0;
    }
    timer() {
        calculate_velocity();
        gWaitCount++;
        if (gWaitCount > 100) { // 10 seconds
            string type = llList2String( gMaterialTypes, gPrimMaterial-1 );
            llOwnerSay(type+" reached maximum velocity of "+(string)gMaxVelMag+
                       " and traveled "+(string)llVecDist(llGetPos(), gHomePosition)+" meters.");
            returnHome();
        }
    }
}
```

</details>

## See also

### Constants

|

| Constant | Type | Value | Description |
| --- | --- | --- | --- |
| [PRIM_MATERIAL_STONE](/constants/PRIM_MATERIAL_STONE/) | integer | `0` | stone |
| [PRIM_MATERIAL_METAL](/constants/PRIM_MATERIAL_METAL/) | integer | `1` | metal |
| [PRIM_MATERIAL_GLASS](/constants/PRIM_MATERIAL_GLASS/) | integer | `2` | glass |
| [PRIM_MATERIAL_WOOD](/constants/PRIM_MATERIAL_WOOD/) | integer | `3` | wood |
| [PRIM_MATERIAL_FLESH](/constants/PRIM_MATERIAL_FLESH/) | integer | `4` | flesh |
| [PRIM_MATERIAL_PLASTIC](/constants/PRIM_MATERIAL_PLASTIC/) | integer | `5` | plastic |
| [PRIM_MATERIAL_RUBBER](/constants/PRIM_MATERIAL_RUBBER/) | integer | `6` | rubber |
| [PRIM_MATERIAL_LIGHT](https://wiki.secondlife.com/wiki/PRIM_MATERIAL_LIGHT) | integer | `7` | light, DEPRECATED: Looks the same as \[ PRIM_FULLBRIGHT, ALL_SIDES, TRUE \] |

<table>
	<tr>
		<th>`material` Flags</th>
		<th></th>
		<th colspan="4">Description</th>
		<th colspan="1">[Friction](/constants/FRICTION/)</th>
		<th colspan="1">[Restitution](/constants/RESTITUTION/)</th>
	</tr>
	<tr>
		<td>0.8</td>
		<td>0.4</td>
	</tr>
	<tr>
		<td>0.3</td>
		<td>0.4</td>
	</tr>
	<tr>
		<td>0.2</td>
		<td>0.7</td>
	</tr>
	<tr>
		<td>0.6</td>
		<td>0.5</td>
	</tr>
	<tr>
		<td>0.9</td>
		<td>0.3</td>
	</tr>
	<tr>
		<td>0.4</td>
		<td>0.7</td>
	</tr>
	<tr>
		<td>0.9</td>
		<td>0.9</td>
	</tr>
	<tr>
		<td colspan="6">light, **DEPRECATED**: Looks the same as \[ [PRIM_FULLBRIGHT](/constants/PRIM_FULLBRIGHT/), [ALL_SIDES](/constants/ALL_SIDES/), [TRUE](/constants/TRUE/) \]</td>
		<td>0.6</td>
		<td>0.5</td>
	</tr>
</table>

### Functions

- [llGetPrimitiveParams](/functions/llGetPrimitiveParams/)

### Events

- [changed](/events/changed/)

---

*Source: [PRIM MATERIAL](https://wiki.secondlife.com/wiki/PRIM_MATERIAL) on the Second Life Wiki. Content from the Second Life Wiki articles PRIM MATERIAL (revision 1194682, 2015-01-23), Template:LSL Constants/PrimitiveParams/materials (revision 1171518, 2012-08-08) and Template:LSL PrimitiveParam Categorize (revision 1180644, 2013-08-09), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/constants/PRIM_MATERIAL/
