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 Socke97 · Apr 27, 2014 at 12:00 AM · c#movementplayervector3motion

Player isn't affected by AddForce(), Lerp() etc.

Hey there, I am trying to make a hook since a loooooong while. Now I am nearly done, but the player isn't moving. So I tried to use my script on another object (a simple sphere) and it worked...

The next thing I did, was disabling all scripts of my player (not the hook script), but the player still didn't move. My hook-scipts: On the player I have got a really simple script, which shoots a sphere as a hook. On the hook itself I have got a script that stops the hook if it's touching something and then move the player to the position of the hook.

Scipt on the hook: using UnityEngine; using System.Collections;

 public class OnHook : MonoBehaviour {
 
     public GameObject player;
     public GameObject hook;
     GameObject other;
 
     public float speed = 20;
 
     public bool grabbed = false;
 
     // Use this for initialization
     void Start () {
 
         other = GameObject.FindWithTag ("Enemy");
     
     }
     
     // Update is called once per frame
     void Update () {
 
         if(grabbed)
         {
 //            other.rigidbody.AddForce((transform.position - other.transform.position).normalized * speed);  // This was my try using addForce
             player.transform.position = Vector3.Lerp(player.transform.position, hook.transform.position, Time.deltaTime * speed);
         }
     
     }
     
 
     void OnTriggerEnter(Collider col){
 
         if(col.tag != "Player" && col.tag != "Hook")
         {
             grabbed = true;
             rigidbody.velocity = Vector3.zero;
         }
 
     }
 }


Thank you for your help!

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 Socke97 · Apr 27, 2014 at 10:00 AM 0
Share

Doesn't anybody know, why my player isn't moving or maybe just an idea?

1 Reply

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

Answer by Bunny83 · Apr 27, 2014 at 10:16 AM

Well, we don't know how your scene is setup, if you have your collision matrix setup correctly ...

Here's a small checklist:

  • The OnHook script is attached to your hook object

  • The hook object has a rigidbody attached.

  • The hook has a primitive collider (sphere, box, ...) or a convex MeshCollider

  • The collider is set to isTrigger.

  • The "hook" variable is linked to the hook object itself (which is actually pointless since you could just use "transform" as this script is on the hook object)

  • The "player" variable is linked to the correct player object.

  • Add a Debug.Log in line 34 to see if the trigger is activated and grabbed is set to true

  • You might also want to set rigidbody.isKinematic to true when you stop the hook so it "really" can't move anymore.

  • Make sure you don't have any other scripts which set the position of the player and interfere with your OnHook script.

  • Make sure that the layers the hook is on and the geometry you want to hit are on layers that can collider with each other.

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 Socke97 · Apr 27, 2014 at 02:49 PM 0
Share

Thank you!!!!!!! Finally i found the problem. You are right I didn't linked the existing player. I linked the prefab. THAN$$anonymous$$ YOU!

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

21 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

Related Questions

Error Vector3 does not contain MoveTowards 3 Answers

3D Character Controller slowing down the higher the slope angle (both up and down) 1 Answer

EnemyHover Script Error? 0 Answers

Making a bubble level (not a game but work tool) 1 Answer

Circular movement of the player 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