Mos

Replacing textures dynamically

Recommended Posts

I'm trying to replace the texture of the decals (created using addDecal), for example: blood, mud, dirt decals. and replace these with custom images i have in a .ytd in a dlc file. i can draw the images to screen. but not on decals.
I'am creating the decals, but when i change decal texture, it disappears. So it makes me think if changing textures in rage requires restarting the game? if that's the case, is there any other ways of achieving this ?

my code:

if (!mp.game.graphics.hasStreamedTextureDictLoaded("myCustomDecals"))
  mp.game.graphics.requestStreamedTextureDict("myCustomDecals", true)

function addDecal (pos, decalType,  width = 1, height = 1, R = 1,G = 1,B = 1,A = 1, timeout = 50) {
  return mp.game.graphics.addDecal(decalType, pos.x, pos.y, pos.z, 0,0,-1, 0,1,0, width, height, R,G,B,A, timeout, false, false, false)
}
// pos = Vector in front of the player
let decal = addDecal(pos, 1010, 100, 100, 0.1,0.1,0.1,1)
// CHANGE_DECAL_TEXTURE native
mp.game.invoke('0x8A35C742130C6080', 1010, 'myCustomDecals', 'decal1')
mp.gui.chat.push('Decal Added: '+ decal)
mp.gui.chat.push('is decal alive: ' +mp.game.invoke('0xC694D74949CAFD0C', decal))

// marker for reference
marker = mp.markers.new(0, pos, 0.15, {
  direction: new mp.Vector3(),
  rotation: new mp.Vector3(),
  color: [255,255,255,255],
  visible: true,
  dimension: player.dimension
})

 

Share this post


Link to post
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.