0
Answered

How to push a player

Pandar 4 months ago in Game Creator updated 4 months ago 9

Hi. Tell me, please, how to push the player with another object (a box, for example)?

Unity version:
Game Creator version:
Answered

Any rigidbody that touches the player will physically react to it and will be pushed. you don't need to do anything.

I need the player to react. The box falls on the player and the player must fall.

+1

use the action character ragdoll when the box hits the player.

Thanks Eagleeyez. There are no other options?

+1

yes, you could use an animation state or gesture.

How would you do that? These are particles. Large clouds of bats (appearing at different intervals) should bring down the character.BatPart.gif

As Marti indicated, the game object that has the bat particles will need a rigidbody, so it can push against the player. You may want to start with a simple box to experiment. This is not specific to GC, but generic Unity stuff, so there are lots of tutorials you can google on working with rigidbodies. Make sure you apply enough force to actually move the box.

The game object that holds the particles and has a rigid body will need a collider and will also need to move to hit the player. A stationary game object with cool particles flying all over the place would have no impact, since it is just sitting in

Note, my understanding is that gestures do not move the location of the player and animation states change the animation to display when the player moves, but it does not actually move the player.

The question is - how to affect the particles on the character without rigidbody.

It seems to work with this script, which weighs on particles.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleForse : MonoBehaviour
{
public GameObject bodyObj;

void OnParticleCollision(GameObject bodyObj)
{
CharacterController body = bodyObj.GetComponent();
if (body)
{
Vector3 direction = bodyObj.transform.position - transform.position;
direction = direction.normalized;
body.Move(direction * 5);
}
}
}