Questions in topic: "falling"https://answers.unity.com/questions/topics/single/2725.html
The latest questions for the topic "falling"How do I make an object fall faster?https://answers.unity.com/questions/1438782/how-do-i-make-an-object-fall-faster.html
I am making a game where the player has to jump on several platforms and collect certain objects in order to win. However, I am having an issue with the player jumping onto the platform. When the player jumps, it floats back down and usually misses the platform because it is still slowly drifting down, and off course. It usually ends up jumping in an arc over the platform rather than landing on the platform itself. Is there a way to make the player jump as high and as fast as it is right now, but fall back down faster with less floating off course?
I have searched Google for answers to no avail, so I could really use some help.
Thanks!playerfallingjumping objectMon, 04 Dec 2017 23:54:44 GMTCLenhoffthe velocity.y has strange values while fallinghttps://answers.unity.com/questions/1417639/the-velocityy-has-strange-values-while-falling.html
Hello everyone ! Please kindly help me with this problem: a 2D game which starts with a player which falls down on a platform. While falling, without pressing ANY key, the velocity.y doesn't only have negative values as it would be logical, but sometimes zero and sometimes positive values, making impossible for me to use different animator states, based on the rb.velocity.y value compared to zero (I'm trying to add a falling animation when the player is falling down to the ground). The documentation for velocity doesn;t help as it never specify these "on the edge" situations.
Please kindly help me with this issue. Thank you !!velocityfallingSun, 08 Oct 2017 11:20:29 GMTSimonaDobre112d multiple falling objectshttps://answers.unity.com/questions/1412082/2d-multiple-falling-objects.html
Hey guys,
I am trying to make a little game where objects fall from the top of the camera. When they are falling you can click on them to destroy them.
This is working well when i am using 10 objects but when i make 100 objects or let them fall in repeat mode the onMouseDown() event is not triggered.
I'm new to Unity and i was wondering if there is something i must be looking for to investigate what is the issue here.
I have the following :
- A gameObject that has a script to make the game objects. I tried to make them in waves with WaitForSeconds, a loop that makes all the objects but then above each other or a invokeRepeating method with a delay.
- My figures are made with a Prefab that has a script that uses the OnMouseDown() to destroy the gameObject. I also tried the normal gravity of a object and `transform.Translate(Vector3.down * fallSpeed * Time.deltaTime, Space.World);` for consistent falling speed.
I also tried the Raycast with :
`if (Input.GetMouseButtonDown(0))
{
Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D hit = Physics2D.Raycast(worldPoint, new Vector3(0,0,1));
Debug.Log("Click");
if (hit.collider != null && hit.collider.gameObject.tag == "Figure")
{
Debug.Log("Destroy : " + hit.collider.name);
Destroy(hit.collider.gameObject);
}
}`
So a small repeat. My problem is that with allot of objects that are falling the click of the mouse does not correctly trigger a destroy on different ways. Appreciate the help thanks :Dfallingremoveclick objectsMon, 25 Sep 2017 21:07:24 GMTSmobelProblem of gravityhttps://answers.unity.com/questions/1406631/problem-of-gravity.html
Good afternoon,
I am currently developing ,me only, a 2d platformer video game,
I use as player , cat asset bought with it animations on spriter pro steam and then transferred with the spriter pro tool to unity ,
This player (cat asset spriter pro) measures on unity 2 meters . 56 cm approximately (2 units . 56) in length includes these ears (I use several polygons collider for each parts of the cat body assembled afterwards with a composite collider with automatic mass , density equal 1 and no physic material 2d),
from the beginning of the development of my project, I always encounter a problem of gravity and acceleration of gravity which influence in an wrong level design and the other parameters of controller movement like jump force value, move force value and run force value ,
and the jump curve was always in the shape of a triangle acute , even with low gravity , with any value of move or run force,
and the jump or fall had a gravity too slight,regardless of the length of the fall,
I asked also before this question on the forum (see this link)
[link text][1]
and I had an answer, it partially corrected these problems, but not completely,
after this topic and acutally, the jump curve is correct (half circle) with some values ​​of move force for each value of gravity,
but the problem is that I attribute the gravity value very roughly without any precision or logic behind,
with initial gravity on y value between -50 and -100 and is always incorrect
(not satisfied with these values ​​because the fall is always slightly slow and not fast as desired despite these abnormally high gravity values)
and with move force which becomes more fast than necessary for these values ​​of gravity to keep the shape of semi-circular jump curve,
not to mention the acceleration of gravity which is low and slow for short falls like the simple jump and on the contrary too fast for a large (the greater the fall, the faster the speed of gravity increases) even for a gravity value of only 15,
otherwise I also noticed that there are no great differences between gravity value of 15 and 100 for the jump,
(all these parameters such as gravity, move force, jump force, run force are apparently linked and the variation of one will affect the others)
here is a part of the source code of the project (that of jumping and moving),
void FixedUpdate ()
{
if ((!Input.GetKey (KeyCode.RightArrow) && !Input.GetKey (KeyCode.LeftArrow)) && Input.GetAxis ("L_XAxis_1") == 0 && Input.GetAxis ("DPad_XAxis_1") == 0) {
h = 0;
rigidBody.velocity = (new Vector2 (h, rigidBody.velocity.y));
wait = true;
anim.SetFloat ("speed", 0f);
} else if (!Input.GetKey (modes.boutonX) && !Input.GetKey (KeyCode.Joystick1Button1)) {
if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis ("L_XAxis_1") > 0 || Input.GetAxis ("DPad_XAxis_1") > 0) {
h = 1;
anim.SetFloat ("speed", 1f);
}
if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis ("L_XAxis_1") < 0 || Input.GetAxis ("DPad_XAxis_1") < 0) {
h = -1;
anim.SetFloat ("speed", 1f);
}
wait = false;
rigidBody.velocity = (new Vector2 (h * moveForce, rigidBody.velocity.y));
anim.SetBool ("X", false);
} else if (Input.GetKey (modes.boutonX) || Input.GetKey (KeyCode.Joystick1Button1)) {
if (!toJump) {
if (Input.GetKey (KeyCode.RightArrow) || Input.GetAxis ("L_XAxis_1") > 0 || Input.GetAxis ("DPad_XAxis_1") > 0) {
h = 1;
anim.SetFloat ("speed", 1f);
}
if (Input.GetKey (KeyCode.LeftArrow) || Input.GetAxis ("L_XAxis_1") < 0 || Input.GetAxis ("DPad_XAxis_1") < 0) {
h = -1;
anim.SetFloat ("speed", 1f);
}
wait = false;
rigidBody.velocity = (new Vector2 (h * maxSpeed, rigidBody.velocity.y));
anim.SetBool ("X", true);
}
}
Jump ();
}
void Jump ()
{
if (Input.GetKeyDown (modes.spaceButton) || (Input.GetAxisRaw ("Jump") > 0 && jump)) {
if (jumpOk) {
if (jumpNumber >= 0) {
jumpNumber--;
up = true;
toJump = true;
rigidBody.velocity = new Vector2 (rigidBody.velocity.x, jumpForce);
jump = false;
}
}
}
if (Input.GetAxisRaw ("Jump") == 0 && !Input.GetKeyDown (modes.spaceButton)) {
jump = true;
}
}
how to correct completely this problem please and what are all the exact values ​​for my character (move force, force force, jump force, gravity value, density, mass etc) ?.
Thank you very much ,
Cordially .
[1]: http://answers.unity3d.com/questions/1388761/how-to-fix-velocity-for-jump-and-movement-or-fall.html2dgravityplatformerjumpingfallingFri, 15 Sep 2017 14:20:08 GMTBioshok7How to fix player from falling an inch when scene starts?https://answers.unity.com/questions/1371014/how-to-fix-player-from-falling-an-inch-when-scene.html
I'm having an issue with my player, when I start the scene, the player falls about an inch from the floor and sounds are playing like a door unlocking (which I do have in my scene) but isnt suppose to make the sound at the beginning of the level.. how do I fix this? someone please help.playerfallingWed, 28 Jun 2017 02:11:56 GMTcrackyourspeakersplayer falls slowlyhttps://answers.unity.com/questions/1363545/player-falls-slowly.html
hi, I am very new to coding and i'm making a 3D top down game
my player moves and jumps pretty nicely and smoothly but falls down slower than an astronaut in space backwards
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float movementSpeed = 30.0f;
private float Vector3;
public float jumpSpeed = 10f;
public float gravity = 9.8f;
void Start () {
Cursor.visible = false;
}
// Update is called once per frame
void Update ()
{
//walking
var x = Input.GetAxis ("Horizontal") * Time.deltaTime * movementSpeed;
var z = Input.GetAxis ("Vertical") * Time.deltaTime * movementSpeed;
transform.Translate (0, 0, z);
transform.Translate (x, 0, 0);
//jump
var y = Input.GetAxis ("Vertical") * Time.deltaTime * movementSpeed;
transform.Translate (0, y, 0);
}
}
i have tried dabbling around with the jump script but keep getting errors i also tried saying that if the space button is pressed the player jumps, then the code waits and after 2 seconds (when the player is it's highest) gravity is subtracted from the heightscripting problemjumpingnewbiefallingFri, 09 Jun 2017 17:59:59 GMTAUSLERCharacterController always starts not Groundedhttps://answers.unity.com/questions/1355229/charactercontroller-always-starts-not-grounded.html
Whenever I start my game, the charactercontroller.IsGrounded is false. How can I make it so that it starts as true? Does it have something to do in with the characterController on the scene? I have it right above the ground and it seems to just go through the floor when I start itcharactercontrollerfallingfloorisgroundedMon, 22 May 2017 15:19:00 GMTkenton84How to make the sphere not fall out of the cylinderhttps://answers.unity.com/questions/1343179/how-to-make-the-sphere-not-fall-out-of-the-cylinde.html
Hi! I have a cylinder and sphere. Sphere has component rigidbody and script moving.
![alt text][1]
[1]: /storage/temp/92440-снимок.png
Similar pc game Proun - Indie Racing Game
How can I do the sphere don't falling and was attached to the cylinder
Thanks a lot!rigidbodygamespherefallingFri, 21 Apr 2017 16:00:53 GMTsiovushMy object is falling through the platformhttps://answers.unity.com/questions/1330423/my-object-is-falling-through-the-platform.html
I was fooling around in unity 5.5 and making a simple game where a rigidbody ball jumps on a platform, but on spawn, it just falls through.
The ball has Sphere Collider enabled, as well as the platform has Box collider enabled.
My ball Inspector: https://gyazo.com/f416684cdbfce560201cface1a084508
My Platform Inspector: https://gyazo.com/37d871e52ea3632dfa2206e9da1b985e
Any answers are much appreciated!
EDIT: I Fixed it, it was the ball was declared as a Trigger.physicsgravityballfallingfalling-through-floorSun, 26 Mar 2017 09:19:25 GMTNotohMake my Cube jump?https://answers.unity.com/questions/1326856/make-my-cube-jump.html
Hey guys I just finished the 3D tutorial so my knowledge is pretty basic, before starting the next tutorial I wanted to try some things out. I did the 3D tutorial and wanted to add a script for jumping, after googleing I used this script:
public float speed;
public float jumpSpeed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int count;
void Start ()
{
rb = GetComponent<Rigidbody> ();
count = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
if(Input.GetKey (KeyCode.Space)){
rb.AddForce(Vector3.up * jumpSpeed);
}
It kinda works, but not like I want it to work, while pressing space it goes in the air, but if I hold space it starts to fly, what do I need to add so it will go up for 1-2 seconds and then fall?
I'm pretty new to unity so an explanation would be great!3djumpfallingThu, 16 Mar 2017 15:16:39 GMTtXxyFPS controller, in wrong (far off map) position at game starthttps://answers.unity.com/questions/1305119/fps-controller-how-to-relocate-at-game-start.html
I am a complete n00b and have just completed my first terrain. I added grassy texture, raised some hills here and there, built a couple of structures, threw some trees at it. Everything was going quite well, I was having a blast walking around my model world, until... I learned how to raise the default terrain height (using a 3rd party script RaiseHeightmap) so that I could put a "sea level" water layer below my land form and sink lakes/pools into the water layer with terrain editor. Then I tried to walk around in Play mode some more to enjoy my new canal and lake system.
Play mode used to work just fine, up until I moved the terrain up i.e. changed the default terrain height. What now appears to be happening is that the FPS controller keeps initialising at the *old* terrain height, so my player starts out looking up at the bottom of the world far above, then immediately falls into endless space as the game starts. I have dragged the FPS controller up above the new terrain height, but whenever I press Play, it snaps right back to the original position and the Big Drop commences. Aaargh!
What I need to know is how to force the FPS controller to remember the new location, some 25 Y units higher than the default. Dragging it in the scene editor doesn't seem to be enough. This is probably a super-stupid question, but I'm new and despite googling I have not yet found a clear answer. Help...
[UPDATE] It occurred to me to wonder whether the FPS character has to start at grid level, so I lowered the whole world carefully until the terrain was just about at gray grid level and the water was below grid. Deleted my FPS controller and added a new one, positioned it just a little bit above the "grassy meadow" of my terrain -- viewed it from various angles to make sure -- and started the game. Boom, I'm looking up at the bottom of the world from a large distance below it. This is driving me crazy...terrainfallingfps controllerSat, 28 Jan 2017 00:02:48 GMTTazlingRigidbody falling not according to physics, only when script is applied.https://answers.unity.com/questions/1298880/rigidbody-falling-slowly-only-when-script-is-appli.html
Hi,
I've read about this topic for the past 3 hours in an attempt to fix it without asking for help, but I just can't find a solution.
The physics in my scene work perfectly for the primitives I have in there, except for my player. The second I add the playerController script to any asset with a Rigidbody on it they stop being affected by physics the same way.
I've tried upping the gravity, changing the scale of the object, and increasing forces artificially (though my current novice skills fail me). Yet here I am still dumbfounded.
If I import a cube, it falls perfectly fine. I attach my script (basic left, right, sprint and jump functions) and it suddenly acts really light and floaty.
Can anybody help me please?
{
public float walkSpeed;
public float runSpeed;
//JUMP VARS
bool playerGrounded = false; //Is the player on the ground?
Collider[] groundCollisions; //??
float groundCheckRadius = 0.2f; //
public LayerMask groundLayer; //Set in Unity, Layer for ground
public Transform groundCheck; //Set in Unity, OBJECT for ground detection
public float jumpHeight; //jump height
bool running;
Rigidbody playerRB;
// Use this for initialization
void Start()
{
playerRB = GetComponent<Rigidbody>();
}
void FixedUpdate () {
//Movement left and right
running = false;
float move = Input.GetAxis("Horizontal"); //Assigns A and D to move +1 or -1
float sprint = Input.GetAxis("Fire3"); //Shift
if ((move > 0 || move < 0) && (sprint > 0 && playerGrounded)) //If A or D && Shift && Grounded
{
playerRB.velocity = new Vector3(move * runSpeed, 0, 0); //This one triggers if moving and holding shift whilst moving
}
else
{
playerRB.velocity = new Vector3(move * walkSpeed, 0, 0); //This one allows movement
}
//----
//JUMPING
//Set the ground check collider
groundCollisions = Physics.OverlapSphere(groundCheck.position, groundCheckRadius, groundLayer);
//Is the player on the ground?
if (groundCollisions.Length > 0) //Array.Length - A collision will add 1 or more to the array
{
playerGrounded = true;
}
else
{
playerGrounded = false;
}
if (playerGrounded && Input.GetAxis("Jump") > 0)
{
playerGrounded = false;
playerRB.velocity = new Vector3(playerRB.velocity.x, 0, 0); //Sets the Y velocity (up/down) to 0 for consistency
playerRB.AddForce(0, jumpHeight, 0, ForceMode.Impulse);
}
} //end of fixed update
}
Any help you can provide will be greatly appreciated, thanks for your time, and I apologise if this question has already been answered, it's now 3am and I've been sat here trying not to pull my own eyes out since midnight. Thanks again.physicsrigidbodyplayer movementfallingMon, 16 Jan 2017 13:13:14 GMTLifeLoopHow can I have the enemies die when they fall through world?https://answers.unity.com/questions/1297120/how-can-i-have-the-enemies-die-when-they-fall-thro.html
I have a script where the scene goes to the next scene when all enemies have died.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Enemy : MonoBehaviour
{
// Number of enemies alive
private static int aliveCounter = 14;
void Start()
{
aliveCounter++;
}
void OnKilled()
{
aliveCounter--;
if (aliveCounter == 0)
SceneManager.LoadScene("Lv.02");
}
}
But some of them don't die and fall through the game world which means the player can never advance. Rather that go on some massive collider hunt I'd rather just kill those enemies who fall through the world. Any idea what code I can attach to this script to make that happen?
Thanks!enemyworldfallingscene-changefalling-through-floorTue, 10 Jan 2017 21:43:05 GMTzachsevenCharacter falls over even though rotation frozenhttps://answers.unity.com/questions/1288341/character-falls-over-even-though-rotation-frozen.html
I can't find an aswer to this anywhere. I froze rotation for my character:
https://i.gyazo.com/52574da4537356abd0793383fc78e19c.png
but she falls over anyways:
https://i.gyazo.com/28673be65b535540ad392866e82ba567.png
Either she is stupid or she is just clumsy.
Help?fallingTue, 20 Dec 2016 19:35:01 GMTRamarauntUnity Falling Damagehttps://answers.unity.com/questions/1285829/unity-falling-damage.html
The following healthbar script is what I have written. Now I want that my player takes falling damage, but I have no clue how I need to do this. Any guidance?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Healthbar : MonoBehaviour {
public Image currentHealthbar;
public Text ratioText;
private float hitpoint = 150;
private float maxHitpoint = 150;
private void Start()
{
UpdateHealthbar ();
}
private void UpdateHealthbar()
{
float ratio = hitpoint / maxHitpoint;
currentHealthbar.rectTransform.localScale = new Vector3 (ratio, 1, 1);
ratioText.text = (ratio * 100).ToString("0") + '%';
}
private void TakeDamage(float damage)
{
hitpoint -= damage;
if (hitpoint <0)
{
hitpoint = 0;
Debug.Log ("Dead!");
}
UpdateHealthbar ();
}
private void HealDamage(float heal)
{
hitpoint += heal;
if (hitpoint >maxHitpoint)
{
hitpoint = maxHitpoint;
}
UpdateHealthbar ();
}
}c#3ddamagefallingThu, 15 Dec 2016 08:54:41 GMTbonjoeri015Standard Asset AIThirdPersonCharacter always on falling animationhttps://answers.unity.com/questions/1278218/standard-asset-aithirdpersoncharacter-always-on-fa.html
The Ethan AIThirdPersonCharacter was working on another computer and worked on this one before, but now in play mode, it's always on it's falling animation, even when it's on the ground, in which case it kind of hovers. I added and baked a NavMesh Agent, Nav static to the ground and a custom audio script. When I remove all the Nav components, it doesn't happen, but I need the character to move. here is the script that controls the animation and movement:
What is it doing and why? Need an answer ***FAST!***
-UPDATE- FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!! the Nav agent was too tall and was embedded in the ground.animationainavmeshagentfallingstandard assetsTue, 29 Nov 2016 22:25:13 GMTNova-1504Death when a character hits the ground from a certain heighthttps://answers.unity.com/questions/1275078/death-when-a-character-hits-the-ground-from-a-cert.html
I'm trying to make my character die when they hit the ground from a height of 4. Can some please help me out I know I'm on the right path, but I can't figure this part out.
public Transform playerPos;
// Update is called once per frame
void Update () {
if (playerPos.position.y > 4)
yield return new WaitUntil(playerPos.position.y = 0);
print("player had died");
}
please help me.heightfallingdeathy-axiskill playerWed, 23 Nov 2016 07:32:48 GMTgmamafilmsHow to make objects fall when the player gets closehttps://answers.unity.com/questions/1268493/how-to-make-objects-fall-when-the-player-gets-clos.html
I have a game where you roll a ball around, collect yellow cubes, and avoid obstacles. I want to know how to add objects to fall when the player gets close.objectdelayfallingfalling-off-moving-thingTue, 08 Nov 2016 01:06:20 GMTMrkrisherMake object fall fasterhttps://answers.unity.com/questions/1246378/make-object-fall-faster.html
Probaly this is just because i didn't configured it correctly, but i think something is wrong with the physics in my projects.
No matter what is the mass of basically anything i make with rigidbody, when those things are in air, they fall ridiculously slow.
For example:
I have a HUGE sphere with 30 tons, and it is in the air, with rigidbody integrated. Instead of it falling immediately, it takes a ridiculous portion of time to fall in to the ground. The same occurs with small spheres, that were supposed to fall immediately. <- I said before that this is just an example, of course i tried with other things.
So... what is wrong? Seriously, it is so robotic!physicsfallingslowlyWed, 21 Sep 2016 02:34:20 GMTZitooxHow to make my character fall when running against a collider.https://answers.unity.com/questions/1244998/how-to-make-my-character-fall-when-running-against.html
Hi, I'm new here, I usually try to solve my problems in Unity searching at google but this time I couldn't get an answer.
So basically I've done a tutorial for a platform 2d game and I copied the script for my player, the problem there is that when I'm running against a wall (with box collider 2D) the player doesn't fall.
using UnityEngine;
using System.Collections;
public class SimplePlatformController : MonoBehaviour {
[HideInInspector] public bool facingRight = true;
[HideInInspector] public bool jump = false;
public float moveForce = 365f;
public float maxSpeed = 5f;
public float jumpForce = 1000f;
public Transform groundCheck;
private bool grounded = false;
private Animator anim;
private Rigidbody2D rb2d;
// Use this for initialization
void Awake ()
{
anim = GetComponent<Animator>();
rb2d = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update ()
{
grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
if (Input.GetButtonDown("Jump") && grounded)
{
jump = true;
}
}
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
anim.SetFloat("Speed", Mathf.Abs(h));
if (h * rb2d.velocity.x < maxSpeed)
rb2d.AddForce(Vector2.right * h * moveForce);
if (Mathf.Abs (rb2d.velocity.x) > maxSpeed)
rb2d.velocity = new Vector2(Mathf.Sign (rb2d.velocity.x) * maxSpeed, rb2d.velocity.y);
if (h > 0 && !facingRight)
Flip ();
else if (h < 0 && facingRight)
Flip ();
if (jump)
{
anim.SetTrigger("Jump");
rb2d.AddForce(new Vector2(0f, jumpForce));
jump = false;
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
The same thing happens when jumping and keep pressing the horizontal button against the wall.
There's the code from the tutorial, I hope you could help me, thanks.jump2d-platformerfallingSat, 17 Sep 2016 16:22:05 GMTYuroiiHow do I make an object instantly drop to the ground (skipping the fall animation)?https://answers.unity.com/questions/1244003/how-do-i-make-an-object-instantly-drop-to-the-grou.html
Now, I have an object wherein I only know the x and z position. If I place it at a very high y coordinate, I would get an animation of it falling down towards the ground. I want to skip this and instantly make it be on the ground. How do I do that?fallinginstantlyThu, 15 Sep 2016 13:35:47 GMTjlawcordovaJumping, Falling and Landing 2Dhttps://answers.unity.com/questions/1238890/jumping-falling-and-landing-2d.html
Hi! I am young and also new with Unity, and I am trying to do a 2D platform game.
First of all, I'm just going to apologise for my bad english, because I am French, but I hope everything is going to be understood!
Okay... For now, my character can move around perfectly. As you may presume I am not coding all alone, I'm following a tutorial series on CasanisPlays' channel, and for now everything worked perfectly. But I did everything like he showed in his video ( https://www.youtube.com/watch?v=0-1fhp2kFlY ), and I am still having 2 errors. I tried for days to fix it, I commented on the video, but no answers and I find this quite sad because making the character jump is a base, and I can't continue to do my game because of those errors. So if someone could fix it and send in the comments the fixed version, I will be so happy !!!
1st one :(11,38): error CS1519: Unexpected symbol `2' in class, struct, or interface member declaration
Second one :(46,13): error CS1525: Unexpected symbol `float'
Here is my script (C#)
using UnityEngine;
using System.Collections;
public class playerControllet : MonoBehaviour {
//movement variables
public float maxSpeed;
//jumping variables
bool grounded = false;
float groundCheckRadius = 0,2f;
public LayerMask groundLayer;
public Transform groundCheck;
public float jumpHeight;
Rigidbody2D myRB;
Animator myAnim;
bool facingRight;
// Use this for initialization
void Start () {
myRB = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();
facingRight = true;
}
// Update is called once per frame
void Update(){
if(grounded && Input.GetAxis("Jump")>0){
grounded = false;
myAnim.SetBool ("isGrounded",grounded);
myRB.AddForce(new Vector2(0,jumpHeight));
}
}
void FixedUpdate() {
//check if we are grounded - if no, then we are falling
grounded = Physics2D.OverlapCircle(groundCheck.position,groundCheckRadius,groundLayer);
myAnim.SetBool ("isGrounded",grounded);
myAnim.SetFloat("VerticalSpeed", myRB.velocity.y)
float move = Input.GetAxis("Horizontal");
myAnim.SetFloat("Speed", Mathf.Abs(move));
myRB.velocity = new Vector2(move * maxSpeed, myRB.velocity.y);
if (move > 0 && !facingRight) {
flip();
} else if (move < 0 && facingRight) {
flip();
}
}
void flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}2djump2d-platformerfallinglandSat, 03 Sep 2016 18:57:12 GMTYukistBike falls while turning after reaching max torquehttps://answers.unity.com/questions/1234214/bike-falls-while-turning-after-reaching-max-torque.html
Okay so after heck of a day, im finally able to drive the bike, not pretty realistic but it is moving at least :P , here comes the issue
1) Even if the motor is as minimum as 1000, the bike falls down on sudden turning on either direction
2) if the torque is decreased, it won't effect anyway, and the bike will fall again.
3) if i try to lower to speed then turn, it will slightly tilt to that direction but will be leaning forward as the tyres are still in contact with terrain.
4) Any help regarding the controller so i can make it super realistic?
void mainBikeMovement(){
float motor = maxMotorTorque * Input.GetAxis ("Vertical");
float Steering = maxSteeringAngle * Input.GetAxis ("Horizontal");
foreach (TiresDetails td in Tires) {
if (td.steering == true) {
td.WheelCollider.steerAngle = Steering;
}
if (td.motor == true) {
td.WheelCollider.motorTorque = motor;
}
applyLocalPositionToVocals (td);
}
}
void applyLocalPositionToVocals(TiresDetails td){
td.WheelMesh.transform.Rotate (Vector3.right, Time.deltaTime * td.WheelCollider.rpm * 10, Space.Self); //to learn
}
![alt text][1]
This is what happens if i turn the bike slowy
[1]: /storage/temp/76860-screen-shot-2016-08-24-at-232245.png
However if i turn without any delay, the bike will fall down after taking a complete circle.
I learnt the script via unity's learning session and it was for a car, so may be that is my issue, any help will be appreciated.euleranglesfallingmotormotorbikemotortorqueThu, 25 Aug 2016 11:37:22 GMTMoonasooperRope Game - How can I make this character fall realistically?https://answers.unity.com/questions/1232616/rope-game-how-can-i-make-this-character-fall-reali.html
Hello everyone,
I've been learning unity for about a month now, and this is the second project I've worked on so far:
https://youtu.be/QCKCv5FZ_JA
Basically when I click somewhere, it generates a rope wich the character is attached to, and when I click again, the rope diseappear.
But when the character falls (without rope), I would like him to fall in a skydiving style, his body being horizontal and his arms and legs going up...
I've tried playing with the settings like drag and angular drag and the weights of the body parts, but with no good results.
Would you know how to do this?? The body parts are all linked with HingeJoints2D.
Thanks in advance !fallingropehingejoint2dSun, 21 Aug 2016 22:09:39 GMTJplecomteHow do I change scenes when player falls off the terrain / The player just keep fallinghttps://answers.unity.com/questions/1229768/how-do-i-change-scenes-when-player-falls-off-the-t.html
In my scene the player can fall off of the terrain by just keep walking or running to the edge of the terrain . I am trying to switch scene and going into gameover scene.terrainplayerfallingMon, 15 Aug 2016 17:06:37 GMTimportguru88falling script flawshttps://answers.unity.com/questions/1225627/falling-script-flaws.html
found a script to detect player falling but there are two problems maybe someone can help with
1. the ray casts from the very bottom of the player - the capsule collider I imagine - and no matter what I do to the parameters of that capsule collider a little bit is always just a tad below the ground so the ray cast is reading below the ground to start with. So mesh colliders are out. I fix this by using a thicker box collider for the ground so that isn't the real problem. the real problem comes when I want to jump from one platform to another. The script works fine if the jump is a fail and I miss the other platform and...fall. BUT, even if the jump is going to be successful, midway across the gap the raycast hits the ground far below and thinks I am falling - thus triggering my fall animation. ANy ideas on how to fix this?. the script is suppose to detect if I am falling thus triggering my "falling" looped animation, playing a scream audio file and also enabling a box collider trigger zone on the ground so when I land - that trigger zone "crashland" takes away all my health as well as triggering an animation of the player crumpling in a heap of broken bones.
2. My work around for the problem of the raycast hitting the ground below mid jump is to have a box collider in that gap to block the raycast from hitting the ground. this box collider is a child of another collider which is a trigger that if i hit it while jumping ( and failing) the trigger gameobject is destroyed - along with the child collider I had blocking the raycast so the ray will then hit the ground and do the whole fallTo My Death bit. But I don't think that is the best solution by any means.![alt text][1]
using UnityEngine;
public class newFallCode : MonoBehaviour
{
public float fallingThreshold = 1f;
public float maxFallingThreshold = 20f;
private float initialDistance = 3f;
private RaycastHit hit;
private Animator anim;
private BoxCollider boxCollider;
GameObject crashland;
AudioSource scream;
void Start()
{
crashland = GameObject.Find ("crashland");
boxCollider = GameObject.Find ("crashland").GetComponent<BoxCollider>();
var dist = 0f;
GetHitDistance(out dist);
initialDistance = dist;
anim = GetComponent <Animator>();
scream = GameObject.Find ("crashland").GetComponent<AudioSource>();
}
bool GetHitDistance(out float distance)
{
distance = 0f;
Ray downRay = new Ray(transform.position, -Vector3.up); // this is the downward ray
if (Physics.Raycast(downRay, out hit))
{
distance = hit.distance;
return true;
}
return false;
}
void Update()
{
var dist = 0f;
if (GetHitDistance(out dist))
{
if (initialDistance < dist)
{
//Get relative distance
var relDistance = dist - initialDistance;
//Are we actually falling?
if (relDistance > fallingThreshold)
{
//How far are we falling
if (relDistance > maxFallingThreshold)
//Debug.Log("Fell off a cliff");
anim.SetTrigger ("Falling");
//How far are we falling
if (relDistance > maxFallingThreshold)
scream.enabled = true;
if (relDistance > maxFallingThreshold)
boxCollider.enabled = true;
}
}
}
else
{
//anim.SetTrigger ("Falling");
Debug.Log("Infinite Fall");
}
}
}
[1]: /storage/temp/75545-fallzone.jpgraycasthitplatformplayer movementfallingFri, 05 Aug 2016 19:17:02 GMTshadowpuppetHow to script a death fall and respawn?https://answers.unity.com/questions/1224457/how-to-script-a-death-fall-and-respawn.html
I really need to know how to make a script which will make my character, which is a First Person Controller (Unity's prefab) die when it falls off one of the roof tops I've made, and when hitting the ground, the player will respawn at the original spawn point. Is this possible? Can it be done all in one single script?
Also, if you could help me too, I need a script to go on to the next level when reaching a "button", I mean, when you step on it, you go on to the next scene. If you could give me these 2 scripts, you'd be saving my life :D
Thanks a lot!
Btw, I've already tried triggers for the second script, this isn't working for me at all.fallingdeathrespawningnext levelWed, 03 Aug 2016 06:38:16 GMTXzileyrecalibrate players Yhttps://answers.unity.com/questions/1223142/recalibrate-players-y.html
I got this script from the forums and modified it a bit to fit my needs. So if the player falls a certain distance, it triggers the" falling" loop animation where the player flails around, and when he hits the ground, it triggers a recoil animation of him landing. that works fine, but when I then try to move the player , the fall loop plays again. I think what is happening is that the script still sees I have fallen that amount to trigger the fall loop again. I need to somehow make the players new Y position after the fall the new zero...that is to say somehow reset that value so the script understands that the new y position is now the starting point for future falls. the "crashenabled" part in the script means that if the player falls far enough that a triggerzone becomes active on the ground which kills him. That works fine because he is dead, the problem is when he falls far enough to trigger the fall loop but not far enough to die
using UnityEngine;
public class newFallCode : MonoBehaviour
{
public float fallingThreshold = 1f;
public float maxFallingThreshold = 20f;
private float initialDistance = 0f;
private RaycastHit hit;
private Animator anim;
private BoxCollider boxCollider;
GameObject crashland;
void Start()
{
boxCollider = GameObject.Find ("crashland").GetComponent<BoxCollider>();
var dist = 0f;
GetHitDistance(out dist);
initialDistance = dist;
anim = GetComponent <Animator>();
}
bool GetHitDistance(out float distance)
{
distance = 0f;
Ray downRay = new Ray(transform.position, -Vector3.up); // this is the downward ray
if (Physics.Raycast(downRay, out hit))
{
distance = hit.distance;
return true;
}
return false;
}
void Update()
{
var dist = 0f;
if (GetHitDistance(out dist))
{
if (initialDistance < dist)
{
//Get relative distance
var relDistance = dist - initialDistance;
//Are we actually falling?
if (relDistance > fallingThreshold)
{
//How far are we falling
if (relDistance > maxFallingThreshold)
Debug.Log("Fell off a cliff");
else anim.SetTrigger ("Falling");
//boxCollider.enabled = true;
//How far are we falling
if (relDistance > maxFallingThreshold)
Debug.Log("crashenabled");
else boxCollider.enabled = true;
}
}
}
else
{
//anim.SetTrigger ("Falling");
Debug.Log("Infinite Fall");
}
}
}fallingvector3.positionSat, 30 Jul 2016 18:17:05 GMTshadowpuppetDoes rotation increase velocity?https://answers.unity.com/questions/1221481/does-rotation-increase-velocity.html
So here's my situation: my character has to fall from a cliff unto a breakable block, but has to fall far enough to get enough energy to break it. I start him off at a set height that I know has worked in the past.
If stumbles off the ledge and rotates, he hits the breakable block with enough force to break it. But if he goes straight down without rotating, his force is so minimal, Unity displays it to me using scientific notation.
Does rotation affect a RigidBody2D's velocity? And if so, what can I do to make the fall generate the same amount of force regardless of my character's rotation?
Also, other things in my game seem to have broken since the last time I used Unity in April 2016. Has Unity changed the way they handle forces and velocity in the last two months since April 2016?rotationvelocityrigidbody2dforcefallingWed, 27 Jul 2016 19:15:08 GMTshieldgenerator7Getting rid of that annoying edge falling bump?https://answers.unity.com/questions/1204686/getting-rid-of-that-annoying-edge-falling-bump.html
Because the default character controller is shaped like a capsule, whenever you run over an edge there's a very annoying dip/bump that happens before gravity takes over. This happens because the bottom of the capsule is rounded so it crawls over the edge until there's nothing to stick to, at which point gravity takes over. Anyone making a serious first-person game would want to get rid of that bump as part of polishing.
If we could change the character controller to a cylinder this wouldn't happen, but we're stuck with the unity capsule. Is there a tweak that gets rid of this, or some other work around?
I'm using UFPS as my first-person kit if there's a solution in there somewhere.charactercontrollerfallingedgesSat, 18 Jun 2016 18:48:57 GMTHoqq