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 headkitgames · Nov 08, 2010 at 07:56 AM · prefabspaint

how to paint gameobjects on other gameobjects

hi there!

is there a known way how to paint gameobjects on other gameobjects or growing some prefabs along a path or something like that?

thanx!

edit: what i had in mind was a little tool to paint on the surface of an object and along this path there would be created the copies of an prefab in predefined distances or "densities"... I will have some additional websearch to find some words to be more clear...

Comment
Add comment · Show 4
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 LeiterJakab · Nov 08, 2010 at 09:52 AM 0
Share

The instantiate function might be what you are looking for. Could you elaborate on what you want to do exactly?

avatar image headkitgames · Nov 08, 2010 at 12:06 PM 0
Share

oh, thats too basic, but thak you. :-) no - sorry if I was too unspecific. I want to "paint" prefabs on gameobjects just like you can "paint" trees on landscapes, if you know what I mean...

avatar image skovacs1 · Nov 08, 2010 at 09:35 PM 0
Share

Saying pretty much the exact same thing again doesn't really make the question more specific or clarify your meaning.

avatar image headkitgames · Nov 11, 2010 at 01:46 PM 0
Share

yeah, thats right.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by skovacs1 · Nov 08, 2010 at 09:43 PM

If I get your meaning, you want to instantiate one or more GameObjects along the surface of another GameObject, is that correct?

To do this, you would raycast and instantiate with the up vector being the normal of the surface that was hit, determining the rest of the new orientation some other way. Positioning is trickier because the object you are instantiating might have the pivot at the center (as opposed to the bottom), so you would have to calculate the offset to the bottom of the GameObject and instantiate at the hit.position + newOrientation * offset.

Comment
Add comment · Show 2 · 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 headkitgames · Nov 11, 2010 at 01:52 PM 0
Share

yes, you understood me right. thanx for the tip! this would be one way. but what i had in $$anonymous$$d was a little easier to use, like a tool to paint on the surface of an object and along this path there would be created the prefabs in predefined distances or "densities"...

avatar image skovacs1 · Nov 12, 2010 at 03:17 PM 0
Share

That's the same, but you would add some sort of ti$$anonymous$$g mechanism to tell how long/hard they hold in a position and you would perform your instantiation based on that. If you wanted the path first so that it could be changed or something, on raycast, ins$$anonymous$$d of instantiating the objects explicitly, you'd mark the points of the path on the surface (either by editing a texture or placing gameObjects that you then store in some sort of public container, etc.) and then when you want to instantiate, you'd read in the texture/gameObjects and instantiate based on that.

avatar image
0

Answer by headkitgames · Nov 19, 2010 at 11:04 AM

so with something like that i could start

function Update() { if (Input.GetButtonDown("Fire1")) { var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hit : RaycastHit;

     if (Physics.Raycast(ray, hit, 100)) 
     {
         var otherObj : GameObject = hit.collider.gameObject;
         Debug.Log("Hit: " + otherObj.name);

         if(otherObj.name == "nameOfObjectToPaintOn")
         {
             var newPos : Vector3 = new Vector3(hit.point.x, 0.8, hit.point.z );

             var newObject : GameObject = Instantiate(thePaintPrefab, newPos, Quaternion.identity) as GameObject;
             newObject.name = "newBulb_" + ++cnt;
             allNewBulbs.Add(newObject); // to store the new positions
         }
     }


 }

}

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

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

No one has followed this question yet.

Related Questions

Spawning letter tiles evenly across screen 0 Answers

Prefab movement towards target 1 Answer

PreFabs, How do they work? Why the object not longer responds to what the script says? 1 Answer

How can I reference a prefab from within itself? 1 Answer

One Prefab and two different object materials 3 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