Search Unity

Trail effect on a physics contact

Discussion in 'Scripting' started by wabuilderman, Jul 30, 2014.

  1. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    If you ever have watched a show called sword art online, you would know what I am look for, but for those who have not (most people); I want it so that, when I swing my sword (a separate physics entity than the player), it will leave behind a thin red trail, that will dissipate after about a second. I will link a picture of the show's effect below. I know I will have to do this through scripting, but I have no clue how to check for a physical contact, and have it ONLY display the effect along the surface of the object.



    Note: I only need those red lines that for an X on the creatures back. not the explosion, or light beams

    I am not asking for a script, simply where to begin.
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    just clarifying: so you want to leave the red lines on the mesh being stuck? do they have to match exactly where the sword hits the target?
     
  3. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    Yes, preferably they would match where the swords struck. But yes, that is the idea. I want it so that when the player attacks, it leaves the red lines on the object attacked.

    Though, preferably this would be a particle, so that i could have it fade after a short period of time.
     
  4. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    Just to clarify (since my profile looks like a total noob) I am not a noob. I have used unity for well over a year, and other 3d software for longer. I am a intermediate java programmer with over three years of experience. I simply just haven't had the need for a unity account, so that is why my account looks like a noobs.
     
  5. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    *Bump* - I still haven't gotten any help.. Just a clue? I really just need an idea on how i would start.
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I think a projector will probably be your best bet - create and orient it where your sword slashed the guy, pointing at your mesh. It'll only really work on striaight lines, though.

    Anything else is going to involve some sort of boolean mesh operations, which gets really complicated really fast.
     
  7. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    Since I kind of need it to be very dynamic, How do I interact with a mesh like that? I am guessing that I would have to detect where on my sword the collision occurred, and the add a particle there, correct? or would I have to dynamically overlay a secondary image to the texture on the mesh?
     
  8. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Hmm... you may be able to raycast upwards from the hilt of the sword; anywhere the ray collides with the target mesh, add to a linerenderer's points or spawn a particle there. That could work. The mesh in question will need to have a MeshCollider though (or, at the least, very accurate compound primitive colliders) to be able to receive the raycast.
     
  9. wabuilderman

    wabuilderman

    Joined:
    Jul 30, 2014
    Posts:
    46
    Ok thanks.