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 ghost012 · Jan 31, 2013 at 10:58 PM · c#javascriptbulletpoolingbullets

Need hep with pooling(call Cs in Js)

Oke so im using Prefactory as my pooling scripts.Prefactory blog

The first problem i had to get over was,how to call to the C# from a Js script and despawning an object. i got it working,though there i now some un needed code in the Js. (im a total rookie in coding)

Note: its about despawning bullet prefab

 private var nonsense : float = 0.0;
 var thisdoesnothign : float = 0;
 var DespawnDelay = 0.0;
 function Awake() {
 }
 function Start(){
 }
 function Update(){
 thisdoesnothign += Time.deltaTime;
 if (thisdoesnothign >= DespawnDelay){
 thisdoesnothign = 0;
 if(nonsense > 0){
 Debug.Log(“nonsense”);
 } else{
 PoolManager.Despawn(gameObject);}
 }
 }

the codes private var nonsense : float = 0.0; and var thisdoesnothign : float = 0; do absolutly nothing,but thats not my biggest concern now.

The problem that im now facing is this code. I need to shoot the bullet prefab from my BSawnPoint(spawnpoint from where to shoot the bullet,the spawn point is invisible and placed in the barrel of the gun.)

 public var bulletPrefab : Transform;
 public var bulletSpeed : float = 6000;
 var ShotDelay = 5.0;
 var timer : float = 0;
 var rotateJoystick : Joystick;
 function Update(){
 if (rotateJoystick.IsFingerDown()){
 timer += Time.deltaTime;
 if (timer >= ShotDelay){
 timer = 0;
 if(!bulletPrefab || !bulletSpeed){
 Debug.Log(“[shoot] ‘bulletPrefab’ or ‘bulletSpeed’ is undefined”);
 } else{
 var bulletCreate = Instantiate(bulletPrefab, GameObject.Find(“BSpawnPoint”).transform.position, Quaternion.identity);
 bulletCreate.rigidbody.AddForce(transform.forward * bulletSpeed);
 
 //PoolManager.Spawn(“Bullet”).rigidbody.AddForce(transform.forward * bulletSpeed); <—Works but does not shoot from gameobject"BSpawnPoint".instead it shoots from x.0 y.0 z.0.
 
 
 }
 }
 }
 }
 function Spawn()<--Function that i used to just spawn and debug/see if the code worked at all.
 {
 PoolManager.Spawn("Bullet");
 }
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 ghost012 · Feb 03, 2013 at 09:02 PM 0
Share

Nobody???

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

9 People are following this question.

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

Related Questions

How to add impact sparks / blood effects to 2D shooter? 2 Answers

Showing a dynamic amount of bullets in a Belt/Magazine/Cylinder 0 Answers

default reference missing in prefabs 0 Answers

GameObject Pool heaving difficulties getting a pool at all trying to find different aproach 1 Answer

The code is giving me errors 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