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 brae · Jan 16, 2013 at 10:34 PM · raycasttimeaxis

raycasting onto an object over time

I working with 1 other and we are trying to ray-cast onto a game object i.e (a grind pole) over a time period of 1 second, were in that second, the ray casting object i.e (board) plays a animation over that second while still moving forward and is at a height of + 1 in y axis or simply on top of the pole collier.

any help would be much obliged

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 iwaldrop · Jan 16, 2013 at 11:03 PM 0
Share

I'm not really sure what you're asking. If you mean that you only want to cast your ray during certain instances then put your raycast into an update loop and activate/deactivate that component depending on whether or not you want to be casting at that moment.

avatar image brae · Jan 16, 2013 at 11:09 PM 0
Share

so when the bored hits the pole collider and only the pole collider, the ray-cast detects that object (being the grind rail) and places the bored ontop of pole and plays animation for 1 second then ray-cast stops and fall back to ground level

1 Reply

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

Answer by iwaldrop · Jan 16, 2013 at 11:22 PM

Well you might give my previous suggestion a shot, and use a script that does a raycast every frame. Use GetHitInfo() to get the hitInfo and turn off the Component when it isn't needed.

 using UnityEngine;
 using System.Collections;
 
 public class PerFrameRayCast : MonoBehaviour
 {
     public LayerMask layersToIgnore;
     
     protected RaycastHit hitInfo;
     protected Transform tr;
     protected int layerMask;
     
     void Awake ()
     {
         tr = transform;
         layerMask = ~layersToIgnore.value;
     }
 
     void Update ()
     {
         Physics.Raycast(tr.position, tr.forward, out hitInfo, Mathf.Infinity, layerMask);
     }
     
     public RaycastHit GetHitInfo () 
     {
         return hitInfo;
     }
 }
Comment
Add comment · Show 4 · 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 brae · Jan 16, 2013 at 11:26 PM 0
Share

sorry i'm not familiar with c# i should of put that in the comment above, so far our game has bean done in java and when mixing code ive been told things can get tricky

avatar image iwaldrop · Jan 16, 2013 at 11:30 PM 0
Share

Indeed mixing code can get a bit hairy. Sorry though, I don't really play around with unityscript. There are some advantages to using it, I'm sure, but I'm a c# guy. :)

I would give this a try though. Since all you're doing it turning it on and off and calling the GetHitInfo() method it should play nicely with the rest of your code.

avatar image brae · Jan 16, 2013 at 11:43 PM 0
Share

thanks for you help ill defiantly look into that

avatar image iwaldrop · Jan 16, 2013 at 11:47 PM 0
Share

Cool! And if it works then you should mark this question as answered by accepting my answer. Otherwise it'll forever be flagged as unanswered. Thanks, and good luck with your game!

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

Ray Casting in 2D 1 Answer

Allow y rotation 1 Answer

Time not slowing down on iPhone 3 Answers

Rotatearound Collider axis 1 Answer

Move Parent Along Childs Local Axis 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