Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by lollypap54 · Oct 27, 2016 at 11:06 AM · prefabprefabsboxcollider2d

Using BoxCollider2D as prefab

So I experienced problem: when i use box collider 2d prefab as my enemies target point, they just don't target at me.

alt text

This variant is working one. I drag active TargetPoint object and my skeleton is targeting normally at me.

alt text

Now for prefab, i can't just draw active one, i have to drag prefab object, but when i do it, it just doesn't work, my skeleton doesn't target that position.

That box collider 2d pos is always updating with player position from controllable script, player presses wasd keys, position updates.

For what do you need to use prefab skeleton ? You just can use that working one where you need to drag active targetpoint, you might say. Well, I want to create enemy spawn system, and i need to use prefab ones.

So what i should do to create working skeleton prefab ? I tried storing that targetpos collider in static variable, but that just doesn't update normally, they attack my position before then.

Thanks for answers!

notworkingone.png (145.6 kB)
workingone.png (125.6 kB)
Comment
Add comment · Show 2
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 hexagonius · Oct 27, 2016 at 08:42 PM 0
Share

So this is what I can say based on what I think I understood:
There's a player and skeletons in the scene. When you drag the player's targetposition onto the Skeleton's Player slot in the inspector, the skeleton follows the player. But if you choose the player prefab's targetposition as the Skeleton's Player variable value, nothing happens. If that's correct so far, that's why:
A prefab is just a blueprint of something you later want a real (virtual acutally) copy of in your game. With Unity's Instantiate method, you can create such an "instance" which would then be available in the scene like all the other's are that have already been put there.
What you need to do is to use Instantiate for spawning your skeletons. after they've been spawned, you need to assign their player variable the player, or you let them find 'em themselves (GameObject.FindWithTag might be a good choice).
What I don't get though is your screenshots showing different players ins$$anonymous$$d of different enemies.

avatar image lollypap54 hexagonius · Oct 28, 2016 at 07:15 AM 0
Share

Thanks for help, I will try it !

0 Replies

· Add your reply
  • Sort: 

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

87 People are following this question.

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

Related Questions

Instantiating A Prefab on my Character Troubles,Instantiating a Prefab 2 Answers

unity 2018.3 prefab overwriting issue 1 Answer

Can you configure prefabs in code? 0 Answers

How do I select all the items in a prefab? 0 Answers

Change only prefab to change all objects 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