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 computron59 · Mar 01, 2016 at 03:28 PM · controlsline renderer

cannot fire second line renderer

Hello. I have two lineRenderers on two separate objects, but only one will fire, I have tried everything I could think of, and then everything the forums suggested. I don't think it is the input settings because other effects on the second object work fine. For reasons I cant comprehend when I fire the second one only the first one fires.

Here is the script for the line renderer;


using UnityEngine; using System.Collections;

public class laserleft : MonoBehaviour {

 public float laserStrength;



 //line
 private LineRenderer lineRenderer;


 // source
 private Transform shipzero;

 // hitpoint
 private RaycastHit hitpnt;

 // Use this for initialization
 void Start () {

     shipzero = gameObject.transform;

     lineRenderer = gameObject.GetComponent<LineRenderer> ();


     // The line is disabled
     lineRenderer.enabled = false;

     // world space i think is ok
     lineRenderer.useWorldSpace = true;

     // this will be over written by the options
     lineRenderer.SetColors( Color.cyan, Color.blue);
 }


 // Update is called once per frame
 void FixedUpdate () {



     // boolean says if it hits. it always will
     bool ifithits = Physics.Raycast (shipzero.position, Vector3.right, out hitpnt , 10000f);

     if (Input.GetButton ("Laser1")) {

         // turns on the line
         lineRenderer.enabled = true;


         lineRenderer.SetPosition (0, new Vector3( shipzero.position.x, shipzero.position.y, shipzero.position.z));
         lineRenderer.SetPosition (1, new Vector3(hitpnt.point.x, shipzero.position.y, shipzero.position.z));


     }
     else {
         lineRenderer.enabled = false;

     }




     // the physics

     if (hitpnt.collider.tag=="ball"){
         hitpnt.rigidbody.AddForceAtPosition(hitpnt.point, Vector3.right*laserStrength);
     }

     // the clause for the other ship
     if (hitpnt.collider.tag== "p1"){
         hitpnt.rigidbody.AddForceAtPosition( hitpnt.point, Vector3.right*laserStrength);
     }


 }

}


The script is pretty much the same for both objects, but facing the other way and calling different linerenderers.

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

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

47 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

Related Questions

First person shooter : Leaning! 2 Answers

Player freaks out when nearing mouse? 0 Answers

How do I get a the movement ofan arm like in truck loader game? 0 Answers

Mouse Look clamping problem 0 Answers

Draw Line from world coordinate to screen coorditate 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