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 /
avatar image
0
Question by PhantomOblivion · Jul 29, 2017 at 03:59 AM · collisionspawning

Spawning a Bullet at The edge of a Cube not the Center

So I have a cube that spawns spheres that travel 'along' a blue line. (I say travel because they actually do not interact. The flight path of the sphere and the blue line are computed completely separately)

And currently, the spheres are spawned at the center of the cube and fly out, however, enemy spheres - that can collide and destroy the ones you create - are colliding with yours inside the cube, which looks confusing because to the user sees nothing happening.alt text

[You are the blue cube, the yellow sphere is what I was talking about they 'fly' down the bright blue line, but enemy spheres also come at you on the same line, thus my problem]

The only idea I had was to destroy the enemy spheres on the surface of the cube using colliders but I don't think that would solve my issue as your spheres would still be spawned inside the blue cube, and you still get a confusing animation if timed right, where you never see anything happening.

Is there a way to find out the collision point between the blue line and the blue cube, because I could use that as my spawn point, however, I don't know of a way to get those coordinates.

Thanks for any help you can give, sorry the vagueness, I don't know how else to describe the problem.

temp-game-capture.png (23.3 kB)
Comment
Add comment · Show 1
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 vir1234 · Jul 29, 2017 at 04:19 AM 0
Share

take one child object at edge into cube and spawn from that child

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by a161803398874 · Jul 29, 2017 at 05:45 AM

@PhantomOblivion hi there! First we need to save with a gameobject the position where you want to spawn the shpere to do this you add an empty game object to the scene and drop it inside your cube("the thing thats shooting") to parent it, now move this empty gameobject where you want to spawn the sphere. . Now in your code set a "public Transform myEmptyGameObject;" then set the "spawnpoint" in your script to this transform location. you will need to drag and drop the "emptygameobject" to the script in the inspector window for it to know what game object we´ve declared on top.

you might need to pass the value of the spawn point as a Vector3 since we´ve declared the name as "myEmptyGameObject" we do it like this. Vector3 newSpawnPos = new Vector3 (myEmptyGameObject.position);

goin to make the code to change position when you click mouse left btn ++++++++++++++++++++++++++++++++++++++++++++++++++++++

 public Transform bullet;
 public Transform myEmptyGameObject;
 Vector3 newSpawnPos = new Vector3 (myEmptyGameObject.position);
 
 if(Input.GetButton("Fire1")
 {
    bullet.position = newSpawnPos;
 }
     
 
 
 
 
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 PhantomOblivion · Jul 29, 2017 at 02:47 PM

@a161803398874 thanks for the reply, however, I am already doing that. I have an empty game object called fire point as a child of the cube. The issue I can fire in any direction.

alt text [The red cube that says 6 is attacking the blue cube and the blue cube is attacking the red cube that says 9]

alt text [This is the Instantiate line I use to spawn the spheres - or as I call them energy Pulses - from the empty game object firePoint]

@vir1234 What I think I am going to do is create four firing points -one for each side of the cube- and then just draw to and spawn from them. I think that system will work later in the game once I start cleaning up the graphics and it will work for now while I am prototyping out the mechanics.


temp-game-capture.png (50.8 kB)
temp-game-capture-2.png (3.5 kB)
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

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

How to delete just one object, both with the same script,How to not delete both objects in a collision? 0 Answers

spawning problem 1 Answer

physics for 2D game 1 Answer

How to make enemies spawn IN the ground without rising up automatically first? 1 Answer

How to instantiate prefabbed objects via array in c# ? 1 Answer


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