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 Clintonsanto · Nov 28, 2015 at 09:29 AM · transformarrayscript.overlapsphereblink

How to get an array of transforms and move GameObject for certain duration to that transforms list

Hi again..

lets go right to the point! so here i want to make player skill similarly more like (Ciri's Blinking Skill = The Witcher 3 game) or (Omnislash = Juggernaut's Dota Hero Skill) but bit different.

so specifically the logic is:

on Getbutton ("Fire")

i want to get an array list of "enemies" gameobject around player's radius and store it (tried using overlapsphere) then get the transforms position of those gameobjects again store it

then automatically it'll move the player position between those all array of transform.positions either consecutively or in random orders for a set of duration and intervals.. i.e keep moving/blinking the player for as long as 10sec and giving 1sec intervals for each, before moving to next transform into another position on the array list

if the time end before the list are complete then return to starting position (inCase the list was more than 10enemies bcs its only 10sec and 1sec between next transform) or if the list of enemies are fewer than 10 then back to array[0] on the list and repeat until the timers end orrrr if the enemies all dead before the timer end just return immediately

and if it possible i want to add additional random XYZ value to each transform on the list so the player doesn't move exactly to the enemies position but only behind,beside,above or below them.

here's what code i already tried

 bool isBlinking;
 RigidBody playerRB;
 
 void Update()
 {
     if (input.GetButton ("Fire1"))
     {
         Seeking();
         isBlinking = true;
         invoke("blinkfalse",10f);
     }
 }
 
 void blinkfalse(){
     isBlinking = false;
 }
 
 
 void Seeking(){
 
     collider[] enemiesInRange = Physics.OverlapSphere(transform.position,blinkRadius)
  
     foreach (collider mobs in enemiesInRange)
     {
         if(mobs.isTrigger != true)
         //bcs i had 2 colliders attached for each enemies 1 isTrigger 1 not
         { 
             EnemyHealth isEnemy = mobs.GetComponent <EnemyHealth>();
             //to make sure its not environments
             if(isEnemy != null)
             {
                 Transform target = isEnemy.GetComponent <Transform>();
                 //get transform data for each gameobjects on the array
                 if(isBlinking)
                 {
                     transform.position = Vector3.Lerp(playerRB.transform, target.transform,1f);
                     //i expect it'll kept moving into each gameobjects transform each 1f before the "isBlinking" turn to false after 10sec
                 }
             }
         }
     }
 }

but the result.. player is blinking only to one enemy on that array and not continuing into next transform on the array, i suspect it only the first one or straight to the last of the list. and had to wait for 10s after isBlinking return to false before i can press fire1 again well this one are actually intended for a limiter so the player won't kept jumpin around all day

about the damage calculations.. i'll add it later after i know how to code about the movement properly

if anyone got simpler method or more advanced coding please teach me because i doubt OverlapSphere are the best way to do so maybe even the worst bcs that is the only way i know to get info of our surrounding radius

THANK YOU VERY MUCH

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Moving multiple transforms from an array in a single script 0 Answers

Parenting GameObject in the scene by scripts. 2 Answers

Storing transforms from objects in Array 1 Answer

Place a object in front the camera in the coordinate 0 of Y axis 2 Answers

How to find the transform of a GameObject from an array. 4 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