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 bawenang · May 04, 2012 at 09:57 AM · collisiontutoriallerpz

Lerpz tutorial problems

Hi guys, firstly I'm a new kid around here. Well met.

Now for the questions, I've got a few questions about the Lerpz / 3D Platformer Tutorial. Currently I'm on the Adversaries chapter. I'm experiencing this problem. BTW, I'm using the newest Unity v 3.5, maybe it has something to do with my problem.

The laser game objects can't do a collision at all. I've done all the necessary steps like the one in the tutorial's pdf. I even added a Debug.Log in the "if (hit.collider.tag == "Player" || hit.collider.tag == "Enemy")" block. But they didn't get triggered at all. But if I put the Debug.Log at the first line in the Update() function it got called, so the script itself is working. What did I do wrong here?

Thanks in advance...

Comment
Add comment · Show 3
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 fafase · May 04, 2012 at 11:26 AM 0
Share

Show how your script looks. Right now you are talking about Update working and collision non-working, I suspect you are using the second in the first one. Collision functions are callbacks, they need to be set outside the Update.

avatar image bawenang · May 07, 2012 at 03:54 AM 0
Share

Well, this is the script:

function Update () { var offset = (1 + $$anonymous$$athf.Sin(Time.time speed + ti$$anonymous$$gOffset)) height / 2; transform.position = originalPosition + Vector3(0, offset, 0);

 //Debug.Log("LaserTrap: Update() ");

 if (Time.time > lastHitTime + 0.25 && Physics.Raycast(transform.position, transform.forward, hit, laserWidth))
 {
     Debug.Log("LaserTrap: Hitting = " + hit.collider.tag); <-- added just now
     
     if (hit.collider.tag == "Player" || hit.collider.tag == "Enemy")
     {
         Instantiate(hitEffect, hit.point, Quaternion.identity);
         hit.collider.Send$$anonymous$$essage("ApplyDamage", damage, Send$$anonymous$$essageOptions.DontRequireReceiver);
         lastHitTime = Time.time;
         
         Debug.Log("LaserTrap: Object hit = " + hit.collider.tag);
     }
 }

}

As you can see, the I've added another debug log because I suspected that the raycasting worked but it didn't recognize the tag. And my suspicion is correct. I got lots of: "LaserTrap: Hitting = Untagged" lines in the console. And as a matter of fact, I haven't tagged the Lerpz with a "Player" tag. $$anonymous$$y bad. :P

Thanks for the answer. :D

PS: How do you post codes here?

avatar image Eric5h5 · May 07, 2012 at 05:03 AM 0
Share

Don't write "solved" in the title, accept the answer.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by bawenang · May 07, 2012 at 05:03 AM

Ok, the problem is solved. I've forgotten to tag the player so everytime the laser hits the player, it is recognized as "Untagged". A little tips here for the tutorial's document, maybe you guys should added that the developer trying this tutorial should re-check again for the tag of the player. Thanks.

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
1

Answer by amirabiri · May 04, 2012 at 10:36 AM

When I did the Lerpz tutorial it was out of date, it was built for Unity 2.x and I was using 3.0 at the time. But perhaps Unity have updated it since then.

Off the top of my head I would say: place a debug statement outside any ifs in the collision callback, check your tags, check the name of the callback against the API reference, and most importantly double check the origin and direction of the ray cast. The latter you can visually inspect when you run the game in the editor by using Debug.DrawLine, but you have to have Gizmos turned on in game view (upper right).

Welcome to Unity :-)

Comment
Add comment · Show 1 · 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 bawenang · May 07, 2012 at 03:58 AM 0
Share

Thank you. Nice to meet you.

Like what I've said on the post above, I've stupidly forgotten to tag the player. So the raycast was detecting it as untagged. Sorry for the false alarm.

Thanks for the answer tho. :D

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

6 People are following this question.

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

Related Questions

Lerpz 3D Platform Tutorial character animation issue with Unity 3.4 2 Answers

Collision detection not triggering 3 Answers

OnTriggerEnter detection too late 0 Answers

Lerpz do not move at all 1 Answer

I am using the Lerpz 3d Platformer Tutorial and I can't find the fire-add material. 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