Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sicorax22 · Aug 12, 2012 at 03:21 AM · rotationplaneheightbloodsplat

how do I change the height of my plane to the height and rotation of the object beneath it?

I am trying to make a blood splatter in unity but am not having much luck. I want to make it so that when you shoot someone, the splatter is created and than it checks where the ground is beneath it, positioning itself on top of the ground (+0.01 or something so it doesn't glitch) and than also rotate to the rotation of the ground (like on a terrain it follows the curve of the hill) so far I have it so that the blood is created and than is set to a height of 0.01 which works fine with a floor at a set position of 0 but if I want to move to a terrain or slanted floor, it wont work because it will be at one set height and rotation. Any help is appreciated.

This is what I have so far.

 var myx = transform.localPosition.x;
  var myz = transform.localPosition.z;
  var initialRot: Quaternion;
  var bloodMats: Material[];
  var changed = false;
  var randomness = 1;
  
 function Awake() {
   transform.rotation = Quaternion.identity; 
    // create a random rotation around Y axis
   var randomRot = Quaternion.Euler(0,Random.Range(-360, 360),0);
   // combine the initial rotation with the random one:
   transform.rotation = randomRot;    
                 
 }
 
 function Update() {
  if (changed == false) {
    var myx = transform.localPosition.x + Random.Range(-randomness,randomness);
    var myz = transform.localPosition.z + Random.Range(-randomness,randomness);
    transform.position = Vector3(myx,0.01,myz);
    mat = Random.Range(0, bloodMats.length);
    renderer.material = bloodMats[mat];
    changed = true;
  }
 
 }

  
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AnXgotta · Aug 12, 2012 at 03:39 AM

If you want to get a spatter in the direction of the bullet hit on a wall or ground what you could do is use a raycast from the player position using the trajectory of the bullet to get a raycast hit on the ground or wall. From this raycast hit on the ground/wall you can get all kinds of information that you could use to do what you need.

Raycast: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html?from=RaycastHit

RaycastHit: http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit.html

If you want to have the blood splatter only on the ground you can use the player collider to get the ground and use the same information from the collision.contacts[0] to get the normal, etc... or just shoot a raycast downward to hit the ground and use the above stated method.

Collision: http://docs.unity3d.com/Documentation/ScriptReference/Collision.html

Edit: You would use the collision normal or do some vector arithmetic to get the angle of the ground. I believe this will get the information you need.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by sicorax22 · Aug 12, 2012 at 05:05 AM

thanks for the reply, I will try to use that. I also read somewhere about decals? could these possibly be used to make blood splats on the floor and surrounding walls? if so how do I go about implementing them? again thanks.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AnXgotta · Aug 12, 2012 at 05:08 AM 0
Share

Just found this...

http://answers.unity3d.com/questions/8494/adding-decals-to-a-object.html

I think this can be applied to your situation.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

turret rotation accuracy problem 0 Answers

Rotate floor plane in-game via C# script 1 Answer

Create plane from 2 Vectors of a symmetry line segment 1 Answer

A small problem with rotating object at mouse position 1 Answer

Flip gameobject by 180º 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges